diff options
author | Klemens Nanni <kn@cvs.openbsd.org> | 2022-10-16 10:44:07 +0000 |
---|---|---|
committer | Klemens Nanni <kn@cvs.openbsd.org> | 2022-10-16 10:44:07 +0000 |
commit | a4fbf77a5aced45b3fa707379e23e09d7470a875 (patch) | |
tree | 9d8c7243c4b26ef39d092d45d968d343e9a741d3 /regress/bin/ksh | |
parent | 2d5dc9ef1f5d84396a4ee49fc9541486470454b4 (diff) |
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...
Diffstat (limited to 'regress/bin/ksh')
-rw-r--r-- | regress/bin/ksh/trap.t | 24 |
1 files changed, 23 insertions, 1 deletions
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 +--- |