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.
This commit is contained in:
parent
8bc610b2ea
commit
f49e62a7eb
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
8
tools/regression/bin/sh/builtins/trap13.0
Normal file
8
tools/regression/bin/sh/builtins/trap13.0
Normal file
@ -0,0 +1,8 @@
|
||||
# $FreeBSD$
|
||||
|
||||
{
|
||||
trap 'exit 0' INT
|
||||
${SH} -c 'kill -INT $PPID'
|
||||
exit 3
|
||||
} &
|
||||
wait $!
|
10
tools/regression/bin/sh/builtins/trap14.0
Normal file
10
tools/regression/bin/sh/builtins/trap14.0
Normal file
@ -0,0 +1,10 @@
|
||||
# $FreeBSD$
|
||||
|
||||
{
|
||||
trap - INT
|
||||
${SH} -c 'kill -INT $PPID' &
|
||||
wait
|
||||
} &
|
||||
wait $!
|
||||
r=$?
|
||||
[ "$r" -gt 128 ] && [ "$(kill -l "$r")" = INT ]
|
Loading…
x
Reference in New Issue
Block a user