possible race condition?

Dave Eisen dkeisen at leland.Stanford.EDU
Fri May 10 07:03:34 AEST 1991


In article <1991May9.144935.20078 at ge-dab.GE.COM> coleman at sunny.dab.ge.com (Richard Coleman) writes:
>
>
>  if (fork() != 0)
>     exit(0);              /* parent process exits */
>  setpgrp();               /* change process group and lose control tty */
>  signal(SIGHUP,SIG_IGN);

>Now my questions is this : when the parent process exits, it sends the
>signal SIGHUP to all processes in its process group.  Is it possible for

This only happens if the parent process is a process group leader which 
won't ordinarily be the case. But, daemons should be paranoid, and
besides, this problem is easy to fix --- just move the signal call
above the first fork and the SIGHUP that might be generated when the
parent dies is safely ignored in the child.



-- 
Dave Eisen                           dkeisen at leland.Stanford.EDU
1101 San Antonio Raod, Suite 102     (Gang-of-Four is being taken off the net)
Mountain View, CA 94043
(415) 967-5644



More information about the Comp.unix.programmer mailing list