summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hush.c3
-rw-r--r--shell/hush.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/hush.c b/hush.c
index 372c957..a58da18 100644
--- a/hush.c
+++ b/hush.c
@@ -1018,7 +1018,8 @@ static int setup_redirects(struct child_prog *prog, int squirrel[])
close(openfd);
} else {
dup2(openfd, redir->fd);
- close(openfd);
+ if (redir->dup == -1)
+ close (openfd);
}
}
}
diff --git a/shell/hush.c b/shell/hush.c
index 372c957..a58da18 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -1018,7 +1018,8 @@ static int setup_redirects(struct child_prog *prog, int squirrel[])
close(openfd);
} else {
dup2(openfd, redir->fd);
- close(openfd);
+ if (redir->dup == -1)
+ close (openfd);
}
}
}