[Ocfs2-tools-devel] [PATCH 2/2] o2hbmonitor: add lockfile

Srinivas Eeda srinivas.eeda at oracle.com
Wed Nov 10 12:36:51 PST 2010


> #define O2HB_SEM_MAGIC_KEY    0x4A32594B
>
> int main()
> {
>    ...
>    daemon();
>    semid = semget(O2HB_SEM_MAGIC_KEY, 1, IPC_CREAT|IPC_EXCL);
>    if (semid < 0) {
>       if (errno = EEXIST)
>          syslog(LOG_INFO "o2hbmonitor is already running.\n");
>       else
>            fprintf(stderr, "failed to get semaphore.\n");
>       exit(semid);
>    }
>    openlog();
>    monitor();
>    sem_close();
> }
Tristan,
thanks for the review and the suggestions :)

If a user kills the process with SIGKILL, then he will be prevented from 
spawning another process until he  explicitly  removes the semaphore. I 
think it adds big inconvenience. If user explicitly removes the lock 
file and starts another process, then it doesn't cause much problems. 
The likely hood of user sending SIGKILL signal is much larger than 
removing the file.



More information about the Ocfs2-tools-devel mailing list