X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fsrc%2Flockfile.c;h=074bbeab939f39d890c968f44dff2a489a117ae5;hb=a917f24ef7b003dcef54a3db2644cf9cb4bc2db2;hp=d65b84e29021c7cd10d7f383a9d4d8a8cea80466;hpb=4acad1f7d56d8228105fdeebe092e2703a361f69;p=util-vserver.git diff --git a/util-vserver/src/lockfile.c b/util-vserver/src/lockfile.c index d65b84e..074bbea 100644 --- a/util-vserver/src/lockfile.c +++ b/util-vserver/src/lockfile.c @@ -30,6 +30,7 @@ #include #include #include +#include static void showHelp(int fd, char const *cmd, int res) @@ -73,12 +74,9 @@ showVersion() exit(0); } -static volatile int timeout_flag = 0; - static void alarmFunc(int UNUSED sig) { - timeout_flag = 1; signal(SIGALRM, alarmFunc); } @@ -93,6 +91,7 @@ int main(int argc, char *argv[]) int fd, sync_fd; int idx = 1; time_t end_time; + pid_t const ppid = getppid(); if (argc>=2) { if (strcmp(argv[1], "--help") ==0) showHelp(1, argv[0], 0); @@ -108,8 +107,6 @@ int main(int argc, char *argv[]) end_time = time(0); if (argc==idx+3) end_time += atoi(argv[idx+2]); else end_time += 300; - - if ((fd=open(argv[idx], O_CREAT|O_RDONLY|O_NOFOLLOW|O_NONBLOCK, 0644))==-1) perror("lockfile: open()"); @@ -120,24 +117,24 @@ int main(int argc, char *argv[]) else if (siginterrupt(SIGALRM, 1)==-1) perror("lockfile: siginterrupt()"); else if (signal(SIGALRM, alarmFunc)==SIG_ERR || - signal(SIGHUP, quitFunc)==SIG_ERR) + signal(SIGHUP, quitFunc) ==SIG_ERR) perror("lockfile: signal()"); - else while (time(0)