siglongjmp() or longjmp() should be safe on all unix systems, though not
others.
You have to be careful: if you receive a SIGCHLD _while_ handling a
SIGINT (or another signal), you must not siglongjmp() out of the inner
handler.
The simplest way get this right is to make sure that the other signal
handlers mask out SIGCHLD while they are running. You will need to use
sigaction() for this, and that isn't as portable as siglongjmp().
> (A comment on LKML in the past suggested that it's not safe on
> cygwin, for example.)
I wrote that comment. At least two versions of cygwin crash when you
call siglongjmp() from a signal handler inside select(). Unfortunately
I did not distill a reliable test for this, to check later versions of
cygwin.
However, given that that _should_ work, I don't think you can rely
write() working under these conditions in cygwin either. So don't
choose a pipe just for this reason.
> >Both would be portable and not special to child handling.
>
> One advantage of the pollable /proc/<pid>, (when combined with
> do_notify_parent() waking tsk->exit_chldwait) is that any process can
> check for the exit of any other process (not just direct children) in a
> select()/poll() call.
Well, pollable /proc/<pid> is not portable at all. If you are going to
use something linux specific, you may as well use pselect() which is
portable to a number of modern unix systems.
enjoy,
-- Jamie
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/