Getting rid of a <defunct> process
Leslie Mikesell
les at chinet.chi.il.us
Mon Feb 13 15:10:36 AEST 1989
In article <27866 at bu-cs.BU.EDU> madd at bu-it.bu.edu (Jim Frost) writes:
>In article <102 at avatar.UUCP> kory at avatar.UUCP (Kory Hamzeh) writes:
>|The main process (the parent which does all of the forks) can not
>|do a wait() because I can't get blocked for anything.
>What I usually do is:
> fireman() /* catches falling children */
> { union wait wstatus;
> while (wait3(&wstatus, WNOHANG, NULL) >= 0)
> ;
> }
> main()
> {
> signal(SIGCHLD, fireman);
> /*...*/
> }
SysV only has wait(), and signals are not queued or deferred inside the
handlers. However, SIGCHLD is a little different (otherwise init would
not work). If a defunct process exists when the signal(SIGCHLD,...)
call is made, the signal happens immediately. Putting a
signal(SIGCHLD,fireman) as the last statement in the fireman() function
will give the effect of queued signals.
Les Mikesell
More information about the Comp.unix.questions
mailing list