System V and SIGCLD
Lindsay F. Marshall
lindsay at cheviot.uucp
Wed May 7 21:33:56 AEST 1986
The following code goes into an infinite loop on System V :-
trap(sig)
int sig;
{
printf("trapped SIGCLD\n");
signal(SIGCLD, trap); /* reset handler */
}
main()
{
signal(SIGCLD, trap);
switch ( fork() )
{
case 0 : /* child */
sleep(5);
exit(0);
case -1 :
printf("error\n");
exit(1);
default :
pause();
}
exit(0);
}
The problem is that resetting the SIGCLD trap inside the handler causes the
signal to be raised again and the handler to be re-entered...... This
is not documented in the manual page and seems to me to be a bug as if you
do not reset the handler the system seems to set it to SIG_DFL, meaning that
you will loose any SIGCLD signals between the handler's exit and your getting
a chance to call signal again. Anyone have any thoughts, information etc. on
this problem??
------------------------------------------------------------------------------
Lindsay F. Marshall, Computing Lab., U of Newcastle upon Tyne, Tyne & Wear, UK
ARPA : lindsay%cheviot.newcastle.ac.uk at ucl-cs.arpa
JANET : lindsay at uk.ac.newcastle.cheviot
UUCP : <UK>!ukc!cheviot!lindsay
-------------------------------------------------------------------------------
More information about the Comp.unix.wizards
mailing list