diff options
-rw-r--r-- | libc/unistd/daemon.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/libc/unistd/daemon.c b/libc/unistd/daemon.c index 0cd827519..bfad7a363 100644 --- a/libc/unistd/daemon.c +++ b/libc/unistd/daemon.c @@ -34,31 +34,31 @@ int daemon( int nochdir, int noclose ) { - int fd; + int fd; - switch (fork()) { - case -1: - return(-1); - case 0: - break; - default: - _exit(0); - } + switch (fork()) { + case -1: + return(-1); + case 0: + break; + default: + _exit(0); + } - if (setsid() == -1) - return(-1); + if (setsid() == -1) + return(-1); - if (!nochdir) - chdir("/"); + if (!nochdir) + chdir("/"); - if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { - dup2(fd, STDIN_FILENO); - dup2(fd, STDOUT_FILENO); - dup2(fd, STDERR_FILENO); - if (fd > 2) - close(fd); - } - return(0); + if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { + dup2(fd, STDIN_FILENO); + dup2(fd, STDOUT_FILENO); + dup2(fd, STDERR_FILENO); + if (fd > 2) + close(fd); + } + return(0); } |