aboutsummaryrefslogtreecommitdiff
path: root/sysklogd/klogd.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-03-29 21:58:33 +0000
committerEric Andersen <andersen@codepoet.org>2001-03-29 21:58:33 +0000
commite5c24dfd010732ab6b80a96ad2a5414499c496c0 (patch)
treee33107a413c5c41e6a7b160ddb310fe43f5ad01d /sysklogd/klogd.c
parent3a6da8c183142a2681a2382b63e970f457cf807b (diff)
downloadbusybox-e5c24dfd010732ab6b80a96ad2a5414499c496c0.tar.gz
Use daemon() to spawn syslogd and klogd daemons.
-Erik
Diffstat (limited to 'sysklogd/klogd.c')
-rw-r--r--sysklogd/klogd.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/sysklogd/klogd.c b/sysklogd/klogd.c
index d5e330bdf..95d4eea65 100644
--- a/sysklogd/klogd.c
+++ b/sysklogd/klogd.c
@@ -124,18 +124,10 @@ static void doKlogd (void)
}
}
-static void daemon_init (char **argv, char *dz, void fn (void))
-{
- setsid(); /* start a new session? */
- strncpy(argv[0], dz, strlen(argv[0]));
- fn();
- exit(0);
-}
-
extern int klogd_main(int argc, char **argv)
{
/* no options, no getopt */
- int opt, pid;
+ int opt;
int doFork = TRUE;
/* do normal option parsing */
@@ -150,15 +142,10 @@ extern int klogd_main(int argc, char **argv)
}
if (doFork == TRUE) {
- pid = fork();
- if (pid < 0)
- exit(pid);
- else if (pid == 0) {
- daemon_init (argv, "klogd", doKlogd);
- }
- } else {
- doKlogd();
+ if (daemon(0, 1) < 0)
+ perror_msg_and_die("daemon");
}
+ doKlogd();
return EXIT_SUCCESS;
}