Don't close file descriptors when we are duplicating them.
authorMatt Kraai <kraai@debian.org>
Tue, 5 Jun 2001 16:50:08 +0000 (16:50 -0000)
committerMatt Kraai <kraai@debian.org>
Tue, 5 Jun 2001 16:50:08 +0000 (16:50 -0000)
hush.c
shell/hush.c

diff --git a/hush.c b/hush.c
index 372c95753198018f7a7e51b84740df40a15b1c4b..a58da189cabdbcdcbe7a49acd072a00ea70b4abb 100644 (file)
--- 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);
                        }
                }
        }
index 372c95753198018f7a7e51b84740df40a15b1c4b..a58da189cabdbcdcbe7a49acd072a00ea70b4abb 100644 (file)
@@ -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);
                        }
                }
        }