1 /* vi: set sw=4 ts=4: */
4 * Functions for debugging and logging as well as some other
5 * simple helper functions.
7 * Russ Dill <Russ.Dill@asu.edu> 2001-2003
8 * Rewritten by Vladimir Oleynik <dzo@simtreas.ru> (C) 2003
10 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
20 #include <sys/socket.h>
28 static int daemonized;
38 * This function makes sure our first socket calls
39 * aren't going to fd 1 (printf badness...) and are
40 * not later closed by daemon()
42 static inline void sanitize_fds(void)
44 int fd = open(bb_dev_null, O_RDWR, 0);
53 void udhcp_background(const char *pidfile)
56 bb_error_msg("Cannot background in uclinux (yet)");
57 #else /* __uClinux__ */
60 /* hold lock during fork. */
61 pid_fd = pidfile_acquire(pidfile);
65 logmode &= ~LOGMODE_STDIO;
66 pidfile_write_release(pid_fd);
67 #endif /* __uClinux__ */
70 void udhcp_start_log_and_pid(const char *pidfile)
74 /* Make sure our syslog fd isn't overwritten */
77 /* do some other misc startup stuff while we are here to save bytes */
78 pid_fd = pidfile_acquire(pidfile);
79 pidfile_write_release(pid_fd);
81 /* equivelent of doing a fflush after every \n */
84 if (ENABLE_FEATURE_UDHCP_SYSLOG) {
85 openlog(applet_name, LOG_PID, LOG_LOCAL0);
86 logmode |= LOGMODE_SYSLOG;
89 bb_info_msg("%s (v%s) started", applet_name, BB_VER);