dup_devnull() did not check the return values of open() and dup2().
Fix this omission.

Signed-off-by: Thomas Rast <tr...@inf.ethz.ch>
---
 run-command.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/run-command.c b/run-command.c
index aece872..1b7f88e 100644
--- a/run-command.c
+++ b/run-command.c
@@ -76,7 +76,10 @@ static inline void close_pair(int fd[2])
 static inline void dup_devnull(int to)
 {
        int fd = open("/dev/null", O_RDWR);
-       dup2(fd, to);
+       if (fd < 0)
+               die_errno(_("open /dev/null failed"));
+       if (dup2(fd, to) < 0)
+               die_errno(_("dup2(%d,%d) failed"), fd, to);
        close(fd);
 }
 #endif
-- 
1.8.3.2.998.g1d087bc

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to