aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/klogd.c
diff options
context:
space:
mode:
authorFelix Janda <felix.janda@posteo.de>2013-08-10 20:18:18 +0200
committerFelix Janda <felix.janda@posteo.de>2013-08-10 20:18:18 +0200
commite49fe14705f78ba5a865ca4efd6ee53c78eeb253 (patch)
tree26b08f12af55b4ea4d08b30a2088e90ba04c6852 /toys/pending/klogd.c
parent35104f47f9d36a9afb43de8c863137fe76c9ff3f (diff)
downloadtoybox-e49fe14705f78ba5a865ca4efd6ee53c78eeb253.tar.gz
Add daemonize function to lib for klogd and syslogd
Diffstat (limited to 'toys/pending/klogd.c')
-rw-r--r--toys/pending/klogd.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/toys/pending/klogd.c b/toys/pending/klogd.c
index 0b638294..da0e4de2 100644
--- a/toys/pending/klogd.c
+++ b/toys/pending/klogd.c
@@ -67,19 +67,7 @@ void klogd_main(void)
sigatexit(handle_signal);
if (toys.optflags & FLAG_c) set_log_level(TT.level); //set log level
- if (!(toys.optflags & FLAG_n)) { //Make it daemon
- pid_t pid;
- int fd = open("/dev/null", O_RDWR);
- if (fd < 0) fd = open("/", O_RDONLY, 0666);
- if((pid = fork()) < 0) perror_exit("DAEMON: fail to fork");
- if (pid) exit(EXIT_SUCCESS);
-
- setsid();
- dup2(fd, 0);
- dup2(fd, 1);
- dup2(fd, 2);
- if (fd > 2) close(fd);
- }
+ if (!(toys.optflags & FLAG_n)) daemonize(); //Make it daemon
if (CFG_KLOGD_SOURCE_RING_BUFFER) {
syslog(LOG_NOTICE, "KLOGD: started with Kernel ring buffer as log source\n");