--- daemon.c 2001/10/04 10:57:22 1.1
+++ daemon.c 2001/10/04 11:00:38 1.2
@@ -14,7 +14,7 @@
#include "daemon.h"
-int daemonize(int nochdir, int noclose)
+int daemonize(void)
{
int fd;
int rc;
@@ -23,10 +23,8 @@
* if we are started from init,
* no need to become daemon.
*/
-#if 0
if (getppid() == 1)
return;
-#endif
/*
* Ignore tty related signals
@@ -94,8 +92,7 @@
* [Equivalently, we could change to any directory containing files
* important to the daemon's operation.]
*/
- if (!nochdir)
- chdir("/");
+ chdir("/");
/*
* give us complete control over the permissions of anything we write. We
@@ -108,7 +105,7 @@
* inherited from our parent process. We have no way of knowing where
* these fds might have been redirected to.
*/
- if (!noclose && (fd = open("/dev/null", O_RDWR, 0)) != -1) {
+ if ((fd = open("/dev/null", O_RDWR, 0)) != -1) {
dup2(fd, STDIN_FILENO);
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
|