Lines 2769-2777
Link Here
|
2769 |
char path[1024]; |
2769 |
char path[1024]; |
2770 |
int fd, l; |
2770 |
int fd, l; |
2771 |
|
2771 |
|
2772 |
if (dhcdbd_daemonize && (daemon (0, 0) == -1)) |
|
|
2773 |
return errno; |
2774 |
|
2775 |
openlog ("dhcdbd", LOG_NDELAY | LOG_CONS, LOG_USER); |
2772 |
openlog ("dhcdbd", LOG_NDELAY | LOG_CONS, LOG_USER); |
2776 |
|
2773 |
|
2777 |
dbus = dbus_svc_init (bus, dhcdbd_destination, dhcdbd_log, 0L); |
2774 |
dbus = dbus_svc_init (bus, dhcdbd_destination, dhcdbd_log, 0L); |
Lines 2812-2817
Link Here
|
2812 |
(dbus, dhcdbd_object_path, path, dhcdbd_if_subscribe, dhco)) |
2809 |
(dbus, dhcdbd_object_path, path, dhcdbd_if_subscribe, dhco)) |
2813 |
return (1); |
2810 |
return (1); |
2814 |
|
2811 |
|
|
|
2812 |
/* Daemonize and write the pidfile write away, to avoid races */ |
2813 |
if (dhcdbd_daemonize && (daemon (0, 0) == -1)) |
2814 |
return errno; |
2815 |
unlink (DHCDBD_PID_FILE); |
2816 |
if ((fd = open (DHCDBD_PID_FILE, O_WRONLY | O_CREAT, 0644)) == -1) |
2817 |
exit (errno); |
2818 |
l = sprintf (path, "%u", getpid ()); |
2819 |
l = write (fd, path, l); |
2820 |
fsync (fd); |
2821 |
close (fd); |
2822 |
|
2815 |
memset (&sa, '\0', sizeof (struct sigaction)); |
2823 |
memset (&sa, '\0', sizeof (struct sigaction)); |
2816 |
sa.sa_sigaction = dhc_reaper; |
2824 |
sa.sa_sigaction = dhc_reaper; |
2817 |
sa.sa_flags = SA_SIGINFO; /* NO RESTART, NO DEFER, CLDSTOP */ |
2825 |
sa.sa_flags = SA_SIGINFO; /* NO RESTART, NO DEFER, CLDSTOP */ |
Lines 2819-2831
Link Here
|
2819 |
dhcdbd_log ("sigaction failed: %s\n", strerror (errno)); |
2827 |
dhcdbd_log ("sigaction failed: %s\n", strerror (errno)); |
2820 |
return (1); |
2828 |
return (1); |
2821 |
} |
2829 |
} |
2822 |
unlink (DHCDBD_PID_FILE); |
2830 |
|
2823 |
if ((fd = open (DHCDBD_PID_FILE, O_WRONLY | O_CREAT, 0644)) == -1) |
|
|
2824 |
exit (errno); |
2825 |
l = sprintf (path, "%u", getpid ()); |
2826 |
l = write (fd, path, l); |
2827 |
fsync (fd); |
2828 |
close (fd); |
2829 |
dhcdbd_log ("Started up."); |
2831 |
dhcdbd_log ("Started up."); |
2830 |
dbus_svc_main_loop (dbus, dhcdbd_work); |
2832 |
dbus_svc_main_loop (dbus, dhcdbd_work); |
2831 |
dhcdbd_debug ("Main Loop Exited."); |
2833 |
dhcdbd_debug ("Main Loop Exited."); |