freebsd-skq/bin/sh/tests/execution/bg13.0
Jilles Tjoelker 1cffe8b812 sh: Keep ignored SIGINT/SIGQUIT after set in a background job
If job control is not enabled, a background job (... &) ignores SIGINT and
SIGQUIT, but this can be reverted using the trap builtin in the same shell
environment.

Using the set builtin to change options would also revert SIGINT and SIGQUIT
to their previous dispositions.

This broke due to r317298. Calling setsignal() reverts the effect of
ignoresig().

Reported by:	bdrewery
MFC after:	1 week
2020-08-28 15:35:45 +00:00

17 lines
369 B
Plaintext

# $FreeBSD$
T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXXXX`
trap 'rm -rf $T' 0
cd $T || exit 3
mkfifo fifo1
# Use a trap, not the default action, since the shell may catch SIGINT and
# therefore its processing may be delayed.
{ set -C; trap 'exit 5' TERM; read dummy <fifo1; exit 4; } &
exec 3>fifo1
kill -INT "$!"
kill -TERM "$!"
exec 3>&-
wait "$!"
r=$?
[ "$r" = 5 ]