abduco

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit d1a44a9c1aa56cc13def314f532fe76f82124219
parent bb7c859b5fff13e8b4afcc0f6878eb0626daef61
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Mon, 16 Feb 2015 22:54:32 +0100

Check return value of open(2) #30720

Diffstat:
abduco.c | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/abduco.c b/abduco.c @@ -347,9 +347,12 @@ static bool create_session(const char *name, char * const argv[]) { chdir("/"); #ifdef NDEBUG int fd = open("/dev/null", O_RDWR); - dup2(fd, 0); - dup2(fd, 1); - dup2(fd, 2); + if (fd != -1) { + dup2(fd, 0); + dup2(fd, 1); + dup2(fd, 2); + close(fd); + } #endif /* NDEBUG */ close(client_pipe[1]); close(server_pipe[1]);