summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2011-01-16 13:56:41 +0000
committerjilles <jilles@FreeBSD.org>2011-01-16 13:56:41 +0000
commit3967e15d578a2539a47faa095aceabb2aa7fee9b (patch)
tree610b187759dee5d5b104edeac20a38f14fa0728b /tools
parent5ca779f63c301bfc79e2b5c70e9149eebd39f8a7 (diff)
downloadFreeBSD-src-3967e15d578a2539a47faa095aceabb2aa7fee9b.zip
FreeBSD-src-3967e15d578a2539a47faa095aceabb2aa7fee9b.tar.gz
sh: If exit is used without args from a trap action, exit on the signal.
This is useful so that it is easier to exit on a signal than to reset the trap to default and resend the signal. It matches ksh93. POSIX says that 'exit' without args from a trap action uses the exit status from the last command before the trap, which is different from 'exit $?' and matches this if the previous command is assumed to have exited on the signal. If the signal is SIGSTOP, SIGTSTP, SIGTTIN or SIGTTOU, or if the default action for the signal is to ignore it, a normal _exit(2) is done with exit status 128+signal_number.
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/bin/sh/builtins/trap6.09
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/builtins/trap6.0 b/tools/regression/bin/sh/builtins/trap6.0
new file mode 100644
index 0000000..bd2bf7e
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/trap6.0
@@ -0,0 +1,9 @@
+# $FreeBSD$
+
+v=$(
+ ${SH} -c 'trap "echo ok; exit" USR1; kill -USR1 $$' &
+ # Suppress possible message about exit on signal
+ wait $! >/dev/null 2>&1
+)
+r=$(kill -l $?)
+[ "$v" = "ok" ] && { [ "$r" = "USR1" ] || [ "$r" = "usr1" ]; }
OpenPOWER on IntegriCloud