xref: /freebsd/bin/sh/tests/execution/killed2.0 (revision cbb3ec25236ba72f91cbdf23f8b78b9d1af0cedf)
1# Most shells print a message when a foreground job is killed by a signal.
2# POSIX allows this, provided the message is sent to stderr, not stdout.
3# Some trickery is needed to capture the message as redirecting stderr of
4# the command itself does not affect it. The colon command ensures that
5# the subshell forks for ${SH}.
6
7exec 3>&1
8r=`(${SH} -c 'kill $$'; :) 2>&1 >&3`
9[ -n "$r" ]
10