lkml.org 
[lkml]   [2001]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH][RFC] Pollable /proc/<pid>/ - avoid SIGCHLD/poll() races
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
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/

\
 
 \ /
  Last update: 2005-03-22 13:08    [W:0.060 / U:1.712 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site