Date: Wed, 30 Oct 2013 21:36:15 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> 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 Message-ID: <201310302136.r9ULaF8x058235@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 ]
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310302136.r9ULaF8x058235>