Re: On SIGCHLD signal semantics

Marc Aurele La France (Marc.La-France@ualberta.ca)
Fri, 7 Jun 1996 10:44:36 -0600 (MDT)


On Wed, 5 Jun 1996, Todd Larason wrote:

> > So the bottom line is what we're doing is allowed by POSIX, and
> > compatible with System V. Given that it's compatible with System V, it
> > may very well be required by SVID and/or Spec 1170. If someone who has
> > access to either SVID or Spec 1170, do please comment on this issue....

> Single Unix Spec's version of System Headers & Interfaces, sigaction()
> description:

> If a process sets the action for the SIGCHLD signal to SIG_IGN, the
> behaviour is unspecified [UX[ except as specified below.

> If the action for the SIGCHLD signal is set to SIG_IGN, child processes
> of the calling processes will not be transformed into zombie processes
> when they terminate. If the calling process subsequently waits for its
> children, and the process has no unwaited for children that were
> transformed into zombie processes, it will block until all of its
> children terminate, and wait(), wait3(), waitid() and waitpid() will
> fail and set errno to [ECHILD]. ]]

> The part between the [UX[ and ]] is a 'Unix extension' to the base X/Open
> spec.

Implementing this in Linux would fix my problem because, when SIGCHLD is
set to SIG_IGN, the only way wait can return a pid is if that child exited
while its parent's SIGCHLD handler was still something other than SIG_IGN.
This means an application must spawn children before it sets SIGCHLD to
SIG_IGN to get the broken behaviour (which strikes me as an explicit
request for the time dependency).

This is not perfect however because applications that expect the BSD
behaviour might still break if they inherit SIG_IGN as their SIGCHLD
handler (although they would do so reliably rather than unreliably). Thus
I would still like to spit out a warning for the first wait call an
application makes with an inherited SIGCHLD handler.

BTW, by "inheritance", I mean inheritance at exec time, not fork time.
That way, things like daemons that fork themselves are not warned about.

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 | |
+----------------------------------+-----------------------------------+