From 709dbbbda82efde2020d9d67a19687c101b91570 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Sun, 21 Jul 2013 18:23:04 +0100
Subject: 31549: Fix third problem with file descriptor management. Replace
ad-hoc subsh_close file descriptor for pipe management with the new job-based
addfilelist() mechanism.
---
Src/exec.c | 18 +-----------------
Src/zsh.h | 1 -
2 files changed, 1 insertion(+), 18 deletions(-)
(limited to 'Src')
diff --git a/Src/exec.c b/Src/exec.c
index f9efb3a19..1c44565f9 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1653,8 +1653,6 @@ execpline(Estate state, wordcode slcode, int how, int last1)
return lastval;
}
-static int subsh_close = -1;
-
/* execute pipeline. This function assumes the `pline' is not NULL. */
/**/
@@ -1731,7 +1729,7 @@ execpline2(Estate state, wordcode pcode,
}
} else {
/* otherwise just do the pipeline normally. */
- subsh_close = pipes[0];
+ addfilelist(NULL, pipes[0]);
execcmd(state, input, pipes[1], how, 0);
}
zclose(pipes[1]);
@@ -1744,8 +1742,6 @@ execpline2(Estate state, wordcode pcode,
execpline2(state, *state->pc++, how, pipes[0], output, last1);
list_pipe = old_list_pipe;
cmdpop();
- zclose(pipes[0]);
- subsh_close = -1;
}
}
@@ -2162,8 +2158,6 @@ addfd(int forked, int *save, struct multio **mfds, int fd1, int fd2, int rflag,
mfds[fd1]->fds[mfds[fd1]->ct++] = fdN;
}
}
- if (subsh_close >= 0 && fdtable[subsh_close] == FDT_UNUSED)
- subsh_close = -1;
}
/**/
@@ -3245,11 +3239,6 @@ execcmd(Estate state, int input, int output, int how, int last1)
if (is_shfunc) {
/* It's a shell function */
-
- if (subsh_close >= 0)
- zclose(subsh_close);
- subsh_close = -1;
-
execshfunc((Shfunc) hn, args);
} else {
/* It's a builtin */
@@ -3325,9 +3314,6 @@ execcmd(Estate state, int input, int output, int how, int last1)
DPUTS(varspc,
"BUG: assignment before complex command");
list_pipe = 0;
- if (subsh_close >= 0)
- zclose(subsh_close);
- subsh_close = -1;
/* If we're forked (and we should be), no need to return */
DPUTS(last1 != 1 && !forked, "BUG: not exiting?");
DPUTS(type != WC_SUBSH, "Not sure what we're doing.");
@@ -5069,7 +5055,6 @@ execsave(void)
es->trapisfunc = trapisfunc;
es->traplocallevel = traplocallevel;
es->noerrs = noerrs;
- es->subsh_close = subsh_close;
es->underscore = ztrdup(zunderscore);
es->next = exstack;
exstack = es;
@@ -5100,7 +5085,6 @@ execrestore(void)
trapisfunc = exstack->trapisfunc;
traplocallevel = exstack->traplocallevel;
noerrs = exstack->noerrs;
- subsh_close = exstack->subsh_close;
setunderscore(exstack->underscore);
zsfree(exstack->underscore);
en = exstack->next;
diff --git a/Src/zsh.h b/Src/zsh.h
index ebd3cb75d..d7b130c72 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -977,7 +977,6 @@ struct execstack {
int trapisfunc;
int traplocallevel;
int noerrs;
- int subsh_close;
char *underscore;
};
--
cgit 1.4.1