run-command: dup_devnull(): guard against syscalls failing

dup_devnull() did not check the return values of open() and dup2(). Fix this omission. Signed-off-by: Thomas Rast <trast@inf.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thomas Rast committed Jul 12, 2013 at 10:58 UTC a77f106c7837faf6a712ea3ac720f5c4fa2feb07
1 file changed +4 -1
run-command.c
+4 -1
@@ -76,7 +76,10 @@ static inline void close_pair(int fd[2])
76 static inline void dup_devnull(int to)
77 {
78 int fd = open("/dev/null", O_RDWR);
79 - dup2(fd, to);
79 + if (fd < 0)
80 + die_errno(_("open /dev/null failed"));
81 + if (dup2(fd, to) < 0)
82 + die_errno(_("dup2(%d,%d) failed"), fd, to);
83 close(fd);
84 }
85 #endif