sm-notify - fix bugs related to run-only-once.
authorNeil Brown <neilb@suse.de>
Thu, 29 Mar 2007 03:07:58 +0000 (13:07 +1000)
committerNeil Brown <neilb@suse.de>
Thu, 29 Mar 2007 03:07:58 +0000 (13:07 +1000)
Make sure that sm-notify really runs only once per reboot.

Signed-off-by: Neil Brown <neilb@suse.de>
utils/statd/sm-notify.c

index cdadcd7..0eb0b09 100644 (file)
@@ -149,7 +149,7 @@ usage:              fprintf(stderr,
        }
 
        if (strcmp(_SM_BASE_PATH, BASEDIR) == 0) {
-               if (record_pid() == 0 && force == 0 && opt_update_state == 0)
+               if (record_pid() == 0 && force == 0 && opt_update_state == 1)
                        /* already run, don't try again */
                        exit(0);
        }
@@ -713,7 +713,7 @@ static int record_pid()
 
        snprintf(pid, 20, "%d\n", getpid());
        fd = open("/var/run/sm-notify.pid", O_CREAT|O_EXCL|O_WRONLY, 0600);
-       if (!fd)
+       if (fd < 0)
                return 0;
        write(fd, pid, strlen(pid));
        close(fd);