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 = xopen(bb_dev_null, O_RDWR);
39 void udhcp_background(const char *pidfile)
42 bb_error_msg("cannot background in uclinux (yet)");
43 #else /* __uClinux__ */
46 /* hold lock during fork. */
47 pid_fd = pidfile_acquire(pidfile);
50 logmode &= ~LOGMODE_STDIO;
51 pidfile_write_release(pid_fd);
52 #endif /* __uClinux__ */
55 void udhcp_start_log_and_pid(const char *pidfile)
59 /* Make sure our syslog fd isn't overwritten */
62 /* do some other misc startup stuff while we are here to save bytes */
63 pid_fd = pidfile_acquire(pidfile);
64 pidfile_write_release(pid_fd);
66 /* equivelent of doing a fflush after every \n */
69 if (ENABLE_FEATURE_UDHCP_SYSLOG) {
70 openlog(applet_name, LOG_PID, LOG_LOCAL0);
71 logmode |= LOGMODE_SYSLOG;
74 bb_info_msg("%s (v%s) started", applet_name, BB_VER);