From a77f106c7837faf6a712ea3ac720f5c4fa2feb07 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Fri, 12 Jul 2013 10:58:36 +0200 Subject: 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 Signed-off-by: Junio C Hamano diff --git a/run-command.c b/run-command.c index 0471219..afc573e 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 -- cgit v0.10.2-6-g49f6