aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stephenson <p.stephenson@samsung.com>2021-08-26 09:46:39 +0100
committerPeter Stephenson <p.stephenson@samsung.com>2021-08-26 09:46:39 +0100
commit0a80579ed18b4004a99b5dc062ce874c0bdc3201 (patch)
treecb10342377e88c80e7f6dae58d1945f49be6501b
parent4a9437317fd374e983934d5b18c7d1d6ee041645 (diff)
downloadzsh-0a80579ed18b4004a99b5dc062ce874c0bdc3201.tar.gz
zsh-0a80579ed18b4004a99b5dc062ce874c0bdc3201.tar.xz
zsh-0a80579ed18b4004a99b5dc062ce874c0bdc3201.zip
49307 with doc update: POSIX_TRAPS fix.
With POSIX_TRAPS set, an ignored signal stays ignored when entering a subshell.
-rw-r--r--ChangeLog6
-rw-r--r--Doc/Zsh/grammar.yo4
-rw-r--r--Doc/Zsh/options.yo13
-rw-r--r--Src/exec.c3
4 files changed, 20 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 428998717..f558bd47c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-08-26 Peter Stephenson <p.w.stephenson@ntlworld.com>
+
+ * 49307 with documentation updated: Src/exec,
+ Doc/Zsh/grammar.yo, Doc/Zsh/options.yo: With POSIX_TRAPS,
+ ignored signals stay that way in subshell.
+
2021-08-24 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 49297 with quoting updated: Src/Modules/files.c: check
diff --git a/Doc/Zsh/grammar.yo b/Doc/Zsh/grammar.yo
index 2eb2018d2..f8f4ada86 100644
--- a/Doc/Zsh/grammar.yo
+++ b/Doc/Zsh/grammar.yo
@@ -288,7 +288,9 @@ for each selection until a break or end-of-file is encountered.
cindex(subshell)
item(tt(LPAR()) var(list) tt(RPAR()))(
Execute var(list) in a subshell. Traps set by the tt(trap) builtin
-are reset to their default values while executing var(list).
+are reset to their default values while executing var(list); an
+exception is that ignored signals will continue to be ignored
+if the option tt(POSIXTRAPS) is set.
)
item(tt({) var(list) tt(}))(
Execute var(list).
diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index 546b16b65..4a8b85e08 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -2330,10 +2330,15 @@ When this option is set, the usual zsh behaviour of executing
traps for tt(EXIT) on exit from shell functions is suppressed.
In that case, manipulating tt(EXIT) traps always alters the global
trap for exiting the shell; the tt(LOCAL_TRAPS) option is
-ignored for the tt(EXIT) trap. Furthermore, a tt(return) statement
-executed in a trap with no argument passes back from the function the
-value from the surrounding context, not from code executed within the
-trap.
+ignored for the tt(EXIT) trap.
+
+Also, a tt(return) statement executed in a trap with no argument passes
+back from the function the value from the surrounding context, not from
+code executed within the trap.
+
+Furthermore, if a trap is set to be ignored, this state persists when
+a subshell is entered. Without the option, the trap would be reset to
+its default state at this point.
)
pindex(SH_FILE_EXPANSION)
pindex(NO_SH_FILE_EXPANSION)
diff --git a/Src/exec.c b/Src/exec.c
index 49ff88b80..79d8064b6 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1033,7 +1033,8 @@ entersubsh(int flags, struct entersubsh_ret *retp)
if (!(flags & ESUB_KEEPTRAP))
for (sig = 0; sig < SIGCOUNT; sig++)
- if (!(sigtrapped[sig] & ZSIG_FUNC))
+ if (!(sigtrapped[sig] & ZSIG_FUNC) &&
+ !(isset(POSIXTRAPS) && (sigtrapped[sig] & ZSIG_IGNORED)))
unsettrap(sig);
monitor = isset(MONITOR);
job_control_ok = monitor && (flags & ESUB_JOB_CONTROL) && isset(POSIXJOBS);