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-w32-e5c24dfd010732ab6b80a96ad2a5414499c496c0.tar.gz
busybox-w32-e5c24dfd010732ab6b80a96ad2a5414499c496c0.tar.bz2
busybox-w32-e5c24dfd010732ab6b80a96ad2a5414499c496c0.zip
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)
124 } 124 }
125} 125}
126 126
127static void daemon_init (char **argv, char *dz, void fn (void))
128{
129 setsid(); /* start a new session? */
130 strncpy(argv[0], dz, strlen(argv[0]));
131 fn();
132 exit(0);
133}
134
135extern int klogd_main(int argc, char **argv) 127extern int klogd_main(int argc, char **argv)
136{ 128{
137 /* no options, no getopt */ 129 /* no options, no getopt */
138 int opt, pid; 130 int opt;
139 int doFork = TRUE; 131 int doFork = TRUE;
140 132
141 /* do normal option parsing */ 133 /* do normal option parsing */
@@ -150,15 +142,10 @@ extern int klogd_main(int argc, char **argv)
150 } 142 }
151 143
152 if (doFork == TRUE) { 144 if (doFork == TRUE) {
153 pid = fork(); 145 if (daemon(0, 1) < 0)
154 if (pid < 0) 146 perror_msg_and_die("daemon");
155 exit(pid);
156 else if (pid == 0) {
157 daemon_init (argv, "klogd", doKlogd);
158 }
159 } else {
160 doKlogd();
161 } 147 }
148 doKlogd();
162 149
163 return EXIT_SUCCESS; 150 return EXIT_SUCCESS;
164} 151}