From 0d33815047847b5c0c174734efa1e4c161da868e Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Fri, 20 Apr 2018 11:17:06 +0100
Subject: 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.
---
Src/exec.c | 7 ++++---
1 file 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
--
cgit 1.4.1