* Undo all redirections. Called on error or interrupt.
*/
-/*
- * Discard all saved file descriptors.
- */
-static void
-clearredir(int drop)
-{
- while (redirlist)
- popredir(drop, /*restore:*/ 0);
-}
-
static int
redirectsafe(union node *redir, int flags)
{
int exerrno;
int applet_no = -1; /* used only by FEATURE_SH_STANDALONE */
- clearredir(/*drop:*/ 1);
envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL);
if (strchr(argv[0], '/') != NULL
#if ENABLE_FEATURE_SH_STANDALONE
static void
setinputfd(int fd, int push)
{
- close_on_exec_on(fd);
if (push) {
pushfile();
g_parsefile->buf = NULL;
}
if (fd < 10)
fd = savefd(fd);
+ else
+ close_on_exec_on(fd);
setinputfd(fd, flags & INPUT_PUSH_FILE);
out:
INT_ON;
tokpushback = 0;
checkkwd = 0;
/* from redir.c: */
- clearredir(/*drop:*/ 0);
+ while (redirlist)
+ popredir(/*drop:*/ 0, /*restore:*/ 0);
}
#if PROFILE