UNIX question

Arturo Perez arturo at humming.UUCP
Wed Dec 25 07:46:27 AEST 1985


In article <12600002 at hpfcls.UUCP> rml at hpfcla.UUCP writes:
>> 
>> The problem is that several children may exit in quick succession.
>> Only one SIGCLD signal will be delivered, since the parent process
>> will (just this once) not manage to run before all have exited.
>> The sigcld handler has no way of determining how many children are
>> to be processed.
>
>It turns out that SIGCLD can be used reliably in System III and V.
>What is missing from the example is a call within the signal handler
>to re-install itself. 
>
>>	int
>>	sigcld()
>>	{
>>		int pid, status;
>>		pid = wait(&status);
>>		...
>>>>		signal(SIGCLD, sigcld);		/* add this line */
>>	}
>
>The signal(2) system call checks to see if any zombie child(ren) are
>present and sends the calling process another SIGCLD if there are.
>The signal handler is thus invoked recursively, once per zombie.
>Note that the reinstallation of the handler must follow the call to
>wait, or infinite recursion results.
>			Bob Lenk
>			{hplabs, ihnp4}!hpfcla!rml


This isn't correct. The problem is that the implicit 'signal(SIGCLD,
SIG_DFL)' is done AFTER the signal trapping function returns. Thus,
if you call signal from within the trapping function it doesn't do
you any good. At least, this is the way it works on our SYSV/BSD
hybrids.  



More information about the Comp.unix mailing list