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.
26 * This function makes sure our first socket calls
27 * aren't going to fd 1 (printf badness...) and are
28 * not later closed by daemon()
30 static inline void sanitize_fds(void)
32 int fd = open(bb_dev_null, O_RDWR, 0);
41 void udhcp_background(const char *pidfile)
44 bb_error_msg("cannot background in uclinux (yet)");
45 #else /* __uClinux__ */
48 /* hold lock during fork. */
49 pid_fd = pidfile_acquire(pidfile);
52 logmode &= ~LOGMODE_STDIO;
53 pidfile_write_release(pid_fd);
54 #endif /* __uClinux__ */
57 void udhcp_start_log_and_pid(const char *pidfile)
61 /* Make sure our syslog fd isn't overwritten */
64 /* do some other misc startup stuff while we are here to save bytes */
65 pid_fd = pidfile_acquire(pidfile);
66 pidfile_write_release(pid_fd);
68 /* equivelent of doing a fflush after every \n */
71 if (ENABLE_FEATURE_UDHCP_SYSLOG) {
72 openlog(applet_name, LOG_PID, LOG_LOCAL0);
73 logmode |= LOGMODE_SYSLOG;
76 bb_info_msg("%s (v%s) started", applet_name, BB_VER);