Re: [PATCH][RFC] Pollable /proc/<pid>/ - avoid SIGCHLD/poll() races

From: Jamie Lokier (
Date: Sat Oct 13 2001 - 10:44:27 EST

Paul Menage wrote:
> >or use sigsetjmp/siglongjmp
> Yes, that would probably solve the situation in question, provided that
> siglongjmp() is portably safe.

siglongjmp() or longjmp() should be safe on all unix systems, though not

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

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

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.

-- Jamie
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Mon Oct 15 2001 - 21:00:49 EST