bin/74404: sh(1) does not handle signals to subshells properly
and/or $! is broken
Jilles Tjoelker
jilles at stack.nl
Sun Apr 5 06:40:03 PDT 2009
The following reply was made to PR bin/74404; it has been noted by GNATS.
From: Jilles Tjoelker <jilles at stack.nl>
To: bug-followup at FreeBSD.org, silby at silby.com
Cc:
Subject: Re: bin/74404: sh(1) does not handle signals to subshells properly
and/or $! is broken
Date: Sun, 5 Apr 2009 15:36:04 +0200
> [ sh forks twice for (somecommand) & ]
It seems reasonable for sh to fork twice here. You can avoid it by doing
{ somecommand; } &.
If I force bash (4.0.10) to fork twice (using { ( sleep 900; echo a );
echo b; } ), it "breaks" the same way as sh does in your example. It
does not "pass on" signals. If you want to pass on signals, do it
manually using the trap builtin.
It would be possible fairly easily to make sh treat (CMD)& as { CMD; }&
but I'm not sure if it's worth it.
--
Jilles Tjoelker
More information about the freebsd-bugs
mailing list