From owner-freebsd-bugs@FreeBSD.ORG Sun Apr 5 13:40:03 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7818B106566C for ; Sun, 5 Apr 2009 13:40:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 65E628FC12 for ; Sun, 5 Apr 2009 13:40:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n35De3Mj079271 for ; Sun, 5 Apr 2009 13:40:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n35De3Mm079270; Sun, 5 Apr 2009 13:40:03 GMT (envelope-from gnats) Date: Sun, 5 Apr 2009 13:40:03 GMT Message-Id: <200904051340.n35De3Mm079270@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Jilles Tjoelker Cc: Subject: Re: bin/74404: sh(1) does not handle signals to subshells properly and/or $! is broken X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Jilles Tjoelker List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Apr 2009 13:40:03 -0000 The following reply was made to PR bin/74404; it has been noted by GNATS. From: Jilles Tjoelker To: bug-followup@FreeBSD.org, silby@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