From: kn Date: Sun, 16 Oct 2022 10:44:06 +0000 (+0000) Subject: Add new trap/errexit/signal test simulating interactive usage X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=047a6e63f068a346477105816641ef1669873bc9;p=openbsd Add new trap/errexit/signal test simulating interactive usage First try add capturing use cases like the bin/ksh/main.c r1.52 one: "[...] we would not run the signal trap if, for example, ^C was pressed and -e was set." With so many different factors (errexit?, receiving (special) signals, traps themselves failing/returing non-zero, running child processes?, etc.) it is very easy to miss subtle behaviour changes during scripting... --- diff --git a/regress/bin/ksh/trap.t b/regress/bin/ksh/trap.t index 35c982da657..c4a4a90a701 100644 --- a/regress/bin/ksh/trap.t +++ b/regress/bin/ksh/trap.t @@ -1,4 +1,4 @@ -# $OpenBSD: trap.t,v 1.5 2022/10/16 10:19:02 kn Exp $ +# $OpenBSD: trap.t,v 1.6 2022/10/16 10:44:06 kn Exp $ # # Check that I/O redirection failure triggers the ERR trap. @@ -122,3 +122,25 @@ expected-stdout: EXIT expected-exit: e == 0 --- + + +name: failed-INTR-runs-EXIT +description: + Check that EXIT runs under errexit even if interrupt handling failed. + SIGINT, SIGQUIT, SIGTERM and SIGHUP are handled specially. + XXX Find/explain the difference if the busy loop runs directly, i.e. not + inside a subshell or process ($PROG -c "..."). +# XXX should always be passed like PROG +arguments: !-e! +env-setup: !ARGS=-e! +stdin: + exec timeout --preserve-status -s INT -- 0.1s $PROG $ARGS -c ' + trap "echo EXIT" EXIT + trap "echo INT ; false" INT + (while : ; do : ; done) + ' +expected-stdout: + INT + EXIT +expected-exit: e != 0 +---