lkml.org 
[lkml]   [1996]   [Jun]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: On SIGCHLD signal semantics
On Tue, 4 Jun 1996 Mark.Hemment@Uniplex.Co.UK wrote:

> > The circumstances addressed are when a parent process decides to wait
> > for termination of one of its child processes, but does so with
> > its SIGCHLD signal handler set to SIG_IGN. If the child process
> > terminates while its parent is waiting, this is not a problem. But
> > if the child terminates before the parent waits, then the parent
> > will be told it has no children (because the kernel has already gotten
> > rid of any indication of the child's existence). This can confuse the
> > parent process.

> wait(2) should fail if a process has no existing unwaited-for child
> processes. errno should be set to ECHILD. The parent shouldn't get
> confused if it is written correctly.
> This is traditional behaviour; I'm sure POSIX.2 hasn't broken it :(

What you say is true, but only if the parent isn't ignoring SIGCHLD or the
child exits before the parent waits. Thus there's a timing problem when
the parent's SIGCHLD handler is SIG_IGN. A wait call by the parent will
return one of two things:

-ECHILD, if the child exits before the parent's wait call; or
the child's pid, if the child exits while the parent is waiting.

It is this discrepancy that can confuse the parent. GNU xargs was one
such parent that got confused before a patch I submitted was integrated
into the current version.

The problem is further compounded by the fact that many programmes (gcc is
one) don't bother doing anything about their SIGCHLD handler before
calling wait. This means that if they happen to inherit a SIGCHLD handler
of SIG_IGN, their behaviour will change.

The warnings introduced by my change are intended to "point the finger" at
those applications (many!) that assume they've inherited a SIGCHLD handler
of SIG_DFL, and those applications that cause others to inherit SIG_IGN.

Marc.

+----------------------------------+-----------------------------------+
| Marc Aurele La France | work: 1-403-492-9310 |
| Computing and Network Services | fax: 1-403-492-1729 |
| 352 General Services Building | email: tsi@ualberta.ca |
| University of Alberta +-----------------------------------+
| Edmonton, Alberta | |
| T6G 2H1 | Standard disclaimers apply |
| CANADA | |
+----------------------------------+-----------------------------------+



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