X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=klogd.c;h=241a99175fa8f4e1c4c6f81711e1c3f1207f17f3;hb=7cf9fed83f6e7bf86eb4cac324b98734739fa861;hp=d5e330bdf75855098f0db48ff53c3e7ab57ca885;hpb=c319601db5296e9d26c7ce0738c4507b51958dda;p=oweals%2Fbusybox.git diff --git a/klogd.c b/klogd.c index d5e330bdf..241a99175 100644 --- a/klogd.c +++ b/klogd.c @@ -40,20 +40,14 @@ #include #include -#if ! defined __GLIBC__ && ! defined __UCLIBC__ -#include -#include - -#ifndef __alpha__ -# define __NR_klogctl __NR_syslog -static inline _syscall3(int, klogctl, int, type, char *, b, int, len); -#else /* __alpha__ */ -#define klogctl syslog -#endif - +#if __GNU_LIBRARY__ < 5 +# ifdef __alpha__ +# define klogctl syslog +# endif #else # include #endif + #include "busybox.h" static void klogd_signal(int sig) @@ -124,18 +118,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 +136,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; }