Attempt to open /dev/null before forking incase it would fail
This commit is contained in:
parent
0c433865d3
commit
0c23c0b1c5
1 changed files with 6 additions and 6 deletions
12
ircd/ircd.c
12
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);
|
||||
|
|
Loading…
Reference in a new issue