summaryrefslogtreecommitdiff
path: root/syslogd.c
diff options
context:
space:
mode:
authorEric Andersen2001-03-29 21:58:33 +0000
committerEric Andersen2001-03-29 21:58:33 +0000
commite5c24dfd010732ab6b80a96ad2a5414499c496c0 (patch)
treee33107a413c5c41e6a7b160ddb310fe43f5ad01d /syslogd.c
parent3a6da8c183142a2681a2382b63e970f457cf807b (diff)
downloadbusybox-e5c24dfd010732ab6b80a96ad2a5414499c496c0.zip
busybox-e5c24dfd010732ab6b80a96ad2a5414499c496c0.tar.gz
Use daemon() to spawn syslogd and klogd daemons.
-Erik
Diffstat (limited to 'syslogd.c')
-rw-r--r--syslogd.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/syslogd.c b/syslogd.c
index cc42c29..e83ce48 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -562,18 +562,9 @@ static void doSyslogd (void)
} /* for main loop */
}
-static void daemon_init (char **argv, char *dz, void fn (void))
-{
- setsid();
- chdir ("/");
- strncpy(argv[0], dz, strlen(argv[0]));
- fn();
- exit(0);
-}
-
extern int syslogd_main(int argc, char **argv)
{
- int opt, pid;
+ int opt;
int doFork = TRUE;
char *p;
@@ -635,15 +626,10 @@ extern int syslogd_main(int argc, char **argv)
#endif
if (doFork == TRUE) {
- pid = fork();
- if (pid < 0)
- exit(pid);
- else if (pid == 0) {
- daemon_init (argv, "syslogd", doSyslogd);
- }
- } else {
- doSyslogd();
+ if (daemon(0, 1) < 0)
+ perror_msg_and_die("daemon");
}
+ doSyslogd();
return EXIT_SUCCESS;
}