confusion about signals

Stephen Weeks MLton@sourcelight.com
Mon, 18 Mar 2002 13:15:31 -0800


> The  way you are SUPPOSED to use sigsuspend, and the reason for the argument,
> is that you block SIGCHLD, then you do the fork, then you do sigsuspend  with
> a mask which lets it get through.  You are now using the fact that sigsuspend
> guarentees that the changing of the blocked mask and the waiting for a signal
> are done atomically.

Makes sense.  But there is still the race after sigsuspend returns,
right?  sigsuspend only guarantees that the signal has been received,
not that the handler has been run.  I was trying to write some code so
that the parent would wait until the handler had been run.  The best I
can think of is to do a sigsuspend and then a busy loop.

> Note,  in  general SIGCHLD is a stupid signal and I don't believe that I have
> ever used it.  If you want to wait for a child to finish, just use wait()  or
> waitpid().   I  can  imagine cases where it might be useful, but they are all
> pretty strange.  What are you using it for?

I wasn't using SIGCHLD for any special reason.  It was just an
available signal.