From 0c23c0b1c526193bac9efb4decee564b2db16b0a Mon Sep 17 00:00:00 2001 From: Aaron Jones Date: Sun, 21 Aug 2016 00:32:34 +0000 Subject: [PATCH] Attempt to open /dev/null before forking incase it would fail --- ircd/ircd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ircd/ircd.c b/ircd/ircd.c index de8e80a4..4e5093fc 100644 --- a/ircd/ircd.c +++ b/ircd/ircd.c @@ -225,6 +225,12 @@ make_daemon(void) we need control over the parent after forking to print the startup message -- Aaron */ + if((nullfd = open("/dev/null", O_RDWR)) < 0) + { + perror("open /dev/null"); + exit(EXIT_FAILURE); + } + if((pid = fork()) < 0) { perror("fork"); @@ -238,12 +244,6 @@ make_daemon(void) exit(EXIT_SUCCESS); } - if((nullfd = open("/dev/null", O_RDWR)) < 0) - { - perror("open /dev/null"); - exit(EXIT_FAILURE); - } - for(fdx = 0; fdx <= 2; fdx++) if (fdx != nullfd) (void) dup2(nullfd, fdx);