about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <p.stephenson@samsung.com>2018-04-20 11:17:06 +0100
committerPeter Stephenson <p.stephenson@samsung.com>2018-04-20 11:17:06 +0100
commit0d33815047847b5c0c174734efa1e4c161da868e (patch)
treef80853204da7f2449aa0d021b36cd67cfef87196
parent9e2afb92987d7fd96a838c15b6641cc1b634a825 (diff)
downloadzsh-0d33815047847b5c0c174734efa1e4c161da868e.tar.gz
zsh-0d33815047847b5c0c174734efa1e4c161da868e.tar.xz
zsh-0d33815047847b5c0c174734efa1e4c161da868e.zip
42693: Fork early for pipelines.
If executing a command not at the end of a pipeline, and
not optimised in the calling code, we can fork before
"prefork" substitutions, at the same point as
for background commands.
-rw-r--r--Src/exec.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 1b622d56f..768e3efe2 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3146,10 +3146,11 @@ execcmd_exec(Estate state, Execcmd_params eparams,
     esprefork = (magic_assign ||
 		 (isset(MAGICEQUALSUBST) && type != WC_TYPESET)) ?
 		 PREFORK_TYPESET : 0;
-    if (how & Z_ASYNC) {
+    if ((how & Z_ASYNC) || (output && !last1)) {
 	/*
-	 * If running in the background, we don't need any of
-	 * the rest of this functino to affect the state in the
+	 * If running in the background, or not the last command in a
+	 * pipeline and not already forked, we don't need any of
+	 * the rest of this function to affect the state in the
 	 * main shell, so fork immediately.
 	 *
 	 * In other cases we may need to process the command line