]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - misc/arpd.c
arpd/ifstat/nstat/rtacct: use daemon()
[mirror_iproute2.git] / misc / arpd.c
index 71cd082e6856330a21d059c70e8dc00513d09b68..128c49d72d64fd628b39740a1fbdedd38545f2b2 100644 (file)
@@ -775,27 +775,9 @@ int main(int argc, char **argv)
 
        load_initial_table();
 
-       if (1) {
-               int fd;
-               pid_t pid = fork();
-
-               if (pid > 0)
-                       _exit(0);
-               if (pid < 0) {
-                       perror("arpd: fork");
-                       goto do_abort;
-               }
-
-               chdir("/");
-               fd = open("/dev/null", O_RDWR);
-               if (fd >= 0) {
-                       dup2(fd, 0);
-                       dup2(fd, 1);
-                       dup2(fd, 2);
-                       if (fd > 2)
-                               close(fd);
-               }
-               setsid();
+       if (daemon(0, 0)) {
+               perror("arpd: daemon");
+               goto do_abort;
        }
 
        openlog("arpd", LOG_PID | LOG_CONS, LOG_DAEMON);