possible race condition?

Ronald S H Khoo ronald at robobar.co.uk
Fri May 10 04:22:41 AEST 1991


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 signal to reach the first child process before it executes setpgrp()
> and changes its process group?  Am I missing something here?

Part of the System V interface definition apparently guarantees the
child to execute before the parent, I hear -- I'd like chapter and
verse from someone who has a copy, if that's not too much trouble.

Anyway, there are some System V variants, like the current 386 Xenix
which runs processes the other way round, where the hangup is
just about guaranteed to hit the child before the setpgrp.
So, in principle, yes, you're right, but the code works correctly
on "real" System V.
-- 
Ronald Khoo <ronald at robobar.co.uk> +44 81 991 1142 (O) +44 71 229 7741 (H)



More information about the Comp.unix.programmer mailing list