From owner-svn-src-all@FreeBSD.ORG Wed Oct 30 21:36:16 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 983828AB; Wed, 30 Oct 2013 21:36:16 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6A1372585; Wed, 30 Oct 2013 21:36:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9ULaGM8058240; Wed, 30 Oct 2013 21:36:16 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9ULaF8x058235; Wed, 30 Oct 2013 21:36:15 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201310302136.r9ULaF8x058235@svn.freebsd.org> From: Jilles Tjoelker Date: Wed, 30 Oct 2013 21:36:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r257399 - in head: bin/sh tools/regression/bin/sh/builtins X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Oct 2013 21:36:16 -0000 Author: jilles Date: Wed Oct 30 21:36:15 2013 New Revision: 257399 URL: http://svnweb.freebsd.org/changeset/base/257399 Log: sh: Allow trapping SIGINT/SIGQUIT after ignore because of '&'. If job control is not enabled, background jobs started with ... & ignore SIGINT and SIGQUIT so that they are not affected by such signals that are intended for the foreground job. However, this should not prevent reassigning a different action for these signals (as if the shell invocation inherited these signal actions from its parent). Austin group issue #751 Example: { trap - INT; exec sleep 10; } & wait A Ctrl+C should terminate the sleep command. Added: head/tools/regression/bin/sh/builtins/trap13.0 (contents, props changed) head/tools/regression/bin/sh/builtins/trap14.0 (contents, props changed) Modified: head/bin/sh/trap.c Modified: head/bin/sh/trap.c ============================================================================== --- head/bin/sh/trap.c Wed Oct 30 21:18:14 2013 (r257398) +++ head/bin/sh/trap.c Wed Oct 30 21:36:15 2013 (r257399) @@ -362,10 +362,12 @@ void ignoresig(int signo) { + if (sigmode[signo] == 0) + setsignal(signo); if (sigmode[signo] != S_IGN && sigmode[signo] != S_HARD_IGN) { signal(signo, SIG_IGN); + sigmode[signo] = S_IGN; } - sigmode[signo] = S_HARD_IGN; } Added: head/tools/regression/bin/sh/builtins/trap13.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/builtins/trap13.0 Wed Oct 30 21:36:15 2013 (r257399) @@ -0,0 +1,8 @@ +# $FreeBSD$ + +{ + trap 'exit 0' INT + ${SH} -c 'kill -INT $PPID' + exit 3 +} & +wait $! Added: head/tools/regression/bin/sh/builtins/trap14.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/builtins/trap14.0 Wed Oct 30 21:36:15 2013 (r257399) @@ -0,0 +1,10 @@ +# $FreeBSD$ + +{ + trap - INT + ${SH} -c 'kill -INT $PPID' & + wait +} & +wait $! +r=$? +[ "$r" -gt 128 ] && [ "$(kill -l "$r")" = INT ]