On 2017-04-25 23:49:56 +0200, Jilles Tjoelker wrote: > On Tue, Apr 25, 2017 at 03:21:24PM +0200, Vincent Lefevre wrote: > > I wonder how the following script is supposed to behave. > > > The POSIX spec seems ambiguous about SIGCHLD trap in a shell. It says: > > "[...] a signal specified using a symbolic name, without the SIG prefix, > > as listed in the tables of signal names in the <signal.h> header defined > > in XBD Headers"; there, SIGCHLD is listed as "Child process terminated, > > stopped, [XSI] or continued". From this spec, I would assume that the > > trap would be executed for any child process that terminates, stops, or > > continues. But this is not what I observe. > > I would not assume that. Since trap actions are not executed while > waiting for a foreground process to exit, it is likely that multiple > instances of SIGCHLD will be coalesced into a single trap action > execution.
IMHO, this would be a bug. A shell should be able to know when all its children have terminated. IMHO, all the pending traps should be executed before the next command. -- Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)