about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2003-11-03 11:33:46 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2003-11-03 11:33:46 +0000
commitd90e97e16a7f9343fbec9d9b33da45806b2a4e89 (patch)
tree5b5ffb0325f2ce8bd80086de1380a74b0a59e345 /Src
parent9644fbfb3f6eea8963f15b91221d22781a3b84bf (diff)
downloadzsh-d90e97e16a7f9343fbec9d9b33da45806b2a4e89.tar.gz
zsh-d90e97e16a7f9343fbec9d9b33da45806b2a4e89.tar.xz
zsh-d90e97e16a7f9343fbec9d9b33da45806b2a4e89.zip
19216: Save and restore pipestatus. Remove debugging output
Diffstat (limited to 'Src')
-rw-r--r--Src/exec.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 0b6948c6e..5b17371bb 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3064,8 +3064,6 @@ getproc(char *cmd)
 	if (!out)
 	{
 	    addproc(pid, NULL, 1);
-	    fprintf(stderr, "Proc %d added\n", pid);
-	    fflush(stderr);
 	}
 	return pnam;
     }
@@ -3448,7 +3446,8 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval)
  * was executed.                                            */
 {
     char **tab, **x, *oargv0;
-    int oldzoptind, oldlastval, oldoptcind;
+    int oldzoptind, oldlastval, oldoptcind, oldnumpipestats;
+    int *oldpipestats = NULL;
     char saveopts[OPT_SIZE], *oldscriptname = scriptname, *fname = dupstring(name);
     int obreaks;
     struct funcstack fstack;
@@ -3463,6 +3462,16 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval)
     if (trapreturn < 0)
 	trapreturn--;
     oldlastval = lastval;
+    oldnumpipestats = numpipestats;
+    if (noreturnval) {
+	/*
+	 * Easiest to use the heap here since we're bracketed
+	 * immediately by a pushheap/popheap pair.
+	 */
+	size_t bytes = sizeof(int)*numpipestats;
+	oldpipestats = (int *)zhalloc(bytes);
+	memcpy(oldpipestats, pipestats, bytes);
+    }
 
     starttrapscope();
 
@@ -3568,8 +3577,11 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval)
 
     if (trapreturn < -1)
 	trapreturn++;
-    if (noreturnval)
+    if (noreturnval) {
 	lastval = oldlastval;
+	numpipestats = oldnumpipestats;
+	memcpy(pipestats, oldpipestats, sizeof(int)*numpipestats);
+    }
     popheap();
 
     if (exit_pending) {