svn commit: trunk/busybox: debianutils include libbb miscutils netw etc...
aldot at busybox.net
aldot at busybox.net
Wed Apr 12 18:09:31 UTC 2006
Author: aldot
Date: 2006-04-12 11:09:26 -0700 (Wed, 12 Apr 2006)
New Revision: 14834
Log:
- patch from Denis Vlasenko to add and use bb_xdaemon()
Added:
trunk/busybox/libbb/bb_xdaemon.c
Modified:
trunk/busybox/debianutils/start_stop_daemon.c
trunk/busybox/include/libbb.h
trunk/busybox/libbb/Makefile.in
trunk/busybox/miscutils/crond.c
trunk/busybox/miscutils/watchdog.c
trunk/busybox/networking/dnsd.c
trunk/busybox/networking/httpd.c
trunk/busybox/networking/inetd.c
trunk/busybox/networking/telnetd.c
trunk/busybox/sysklogd/klogd.c
trunk/busybox/sysklogd/syslogd.c
Changeset:
Modified: trunk/busybox/debianutils/start_stop_daemon.c
===================================================================
--- trunk/busybox/debianutils/start_stop_daemon.c 2006-04-12 17:55:51 UTC (rev 14833)
+++ trunk/busybox/debianutils/start_stop_daemon.c 2006-04-12 18:09:26 UTC (rev 14834)
@@ -275,8 +275,7 @@
}
*--argv = startas;
if (opt & SSD_OPT_BACKGROUND) {
- if (daemon(0, 0) == -1)
- bb_perror_msg_and_die ("unable to fork");
+ bb_xdaemon(0, 0);
setsid();
}
if (opt & SSD_OPT_MAKEPID) {
Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h 2006-04-12 17:55:51 UTC (rev 14833)
+++ trunk/busybox/include/libbb.h 2006-04-12 18:09:26 UTC (rev 14834)
@@ -146,6 +146,7 @@
extern void xstat(const char *filename, struct stat *buf);
extern int bb_xsocket(int domain, int type, int protocol);
+extern void bb_xdaemon(int nochdir, int noclose);
#define BB_GETOPT_ERROR 0x80000000UL
extern const char *bb_opt_complementally;
Modified: trunk/busybox/libbb/Makefile.in
===================================================================
--- trunk/busybox/libbb/Makefile.in 2006-04-12 17:55:51 UTC (rev 14833)
+++ trunk/busybox/libbb/Makefile.in 2006-04-12 18:09:26 UTC (rev 14834)
@@ -30,7 +30,7 @@
trim.c u_signal_names.c vdprintf.c verror_msg.c \
vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c xstat.c \
xgethostbyname.c xgethostbyname2.c xreadlink.c xregcomp.c xgetlarg.c \
- bb_xsocket.c \
+ bb_xsocket.c bb_xdaemon.c \
get_terminal_width_height.c fclose_nonstdin.c fflush_stdout_and_exit.c \
getopt_ulflags.c default_error_retval.c wfopen_input.c speed_table.c \
perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c bb_askpass.c \
Added: trunk/busybox/libbb/bb_xdaemon.c
===================================================================
--- trunk/busybox/libbb/bb_xdaemon.c 2006-04-12 17:55:51 UTC (rev 14833)
+++ trunk/busybox/libbb/bb_xdaemon.c 2006-04-12 18:09:26 UTC (rev 14834)
@@ -0,0 +1,17 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * bb_xdaemon.c - a daemon() which dies on failure with error message
+ *
+ * Copyright (C) 2006 Denis Vlasenko
+ *
+ * Licensed under LGPL, see file docs/lesser.txt in this tarball for details.
+ */
+#include <unistd.h>
+#include "libbb.h"
+
+void bb_xdaemon(int nochdir, int noclose)
+{
+ if (daemon(nochdir, noclose))
+ bb_perror_msg_and_die("daemon");
+}
+
Modified: trunk/busybox/miscutils/crond.c
===================================================================
--- trunk/busybox/miscutils/crond.c 2006-04-12 17:55:51 UTC (rev 14833)
+++ trunk/busybox/miscutils/crond.c 2006-04-12 18:09:26 UTC (rev 14834)
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
/*
* crond -d[#] -c <crondir> -f -b
*
@@ -213,9 +214,7 @@
/* reexec for vfork() do continue parent */
vfork_daemon_rexec(1, 0, ac, av, "-f");
#else /* uClinux */
- if (daemon(1, 0) < 0) {
- bb_perror_msg_and_die("daemon");
- }
+ bb_xdaemon(1, 0);
#endif /* uClinux */
}
Modified: trunk/busybox/miscutils/watchdog.c
===================================================================
--- trunk/busybox/miscutils/watchdog.c 2006-04-12 17:55:51 UTC (rev 14833)
+++ trunk/busybox/miscutils/watchdog.c 2006-04-12 18:09:26 UTC (rev 14834)
@@ -40,8 +40,7 @@
if (optind < argc - 1 || argc == 1)
bb_show_usage();
- if (daemon(0, 1) < 0)
- bb_perror_msg_and_die("Failed forking watchdog daemon");
+ bb_xdaemon(0, 1);
signal(SIGHUP, watchdog_shutdown);
signal(SIGINT, watchdog_shutdown);
Modified: trunk/busybox/networking/dnsd.c
===================================================================
--- trunk/busybox/networking/dnsd.c 2006-04-12 17:55:51 UTC (rev 14833)
+++ trunk/busybox/networking/dnsd.c 2006-04-12 18:09:26 UTC (rev 14834)
@@ -5,6 +5,7 @@
* Copyright (C) 2005 Roberto A. Foglietta (me at roberto.foglietta.name)
* Copyright (C) 2005 Odd Arild Olsen (oao at fibula dot no)
* Copyright (C) 2003 Paul Sheer
+ *
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* Odd Arild Olsen started out with the sheerdns [1] of Paul Sheer and rewrote
@@ -408,9 +409,7 @@
/* reexec for vfork() do continue parent */
vfork_daemon_rexec(1, 0, argc, argv, "-d");
#else /* uClinux */
- if (daemon(1, 0) < 0) {
- bb_perror_msg_and_die("daemon");
- }
+ bb_xdaemon(1, 0);
#endif /* uClinuvx */
dnsentryinit(is_verbose());
Modified: trunk/busybox/networking/httpd.c
===================================================================
--- trunk/busybox/networking/httpd.c 2006-04-12 17:55:51 UTC (rev 14833)
+++ trunk/busybox/networking/httpd.c 2006-04-12 18:09:26 UTC (rev 14834)
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
/*
* httpd implementation for busybox
*
@@ -2114,8 +2115,7 @@
#if !ENABLE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
# if !DEBUG
- if (daemon(1, 0) < 0) /* don`t change curent directory */
- bb_perror_msg_and_die("daemon");
+ bb_xdaemon(1, 0); /* don`t change curent directory */
# endif
return miniHttpd(server);
#else
Modified: trunk/busybox/networking/inetd.c
===================================================================
--- trunk/busybox/networking/inetd.c 2006-04-12 17:55:51 UTC (rev 14833)
+++ trunk/busybox/networking/inetd.c 2006-04-12 18:09:26 UTC (rev 14834)
@@ -1314,7 +1314,7 @@
/* reexec for vfork() do continue parent */
vfork_daemon_rexec (0, 0, argc, argv, "-f");
#else
- daemon (0, 0);
+ daemon (0, 0); /* bb_xdaemon? */
#endif /* uClinux */
} else {
setsid ();
@@ -1802,3 +1802,4 @@
(void) sendto (s, buffer, strlen (buffer), 0, &sa, sizeof (sa));
}
#endif /* CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME */
+/* vi: set sw=4 ts=4: */
Modified: trunk/busybox/networking/telnetd.c
===================================================================
--- trunk/busybox/networking/telnetd.c 2006-04-12 17:55:51 UTC (rev 14833)
+++ trunk/busybox/networking/telnetd.c 2006-04-12 18:09:26 UTC (rev 14834)
@@ -1,4 +1,4 @@
-/* vi:set ts=4:*/
+/* vi: set sw=4 ts=4: */
/*
* Simple telnet server
* Bjorn Wesen, Axis Communications AB (bjornw at axis.com)
@@ -469,10 +469,8 @@
bb_perror_msg_and_die("listen");
}
- if (daemon(0, 0) < 0)
- bb_perror_msg_and_die("daemon");
+ bb_xdaemon(0, 0);
-
maxfd = master_fd;
#endif /* CONFIG_FEATURE_TELNETD_INETD */
Modified: trunk/busybox/sysklogd/klogd.c
===================================================================
--- trunk/busybox/sysklogd/klogd.c 2006-04-12 17:55:51 UTC (rev 14833)
+++ trunk/busybox/sysklogd/klogd.c 2006-04-12 18:09:26 UTC (rev 14834)
@@ -121,8 +121,7 @@
#if defined(__uClinux__)
vfork_daemon_rexec(0, 1, argc, argv, "-n");
#else /* __uClinux__ */
- if (daemon(0, 1) < 0)
- bb_perror_msg_and_die("daemon");
+ bb_xdaemon(0, 1);
#endif /* __uClinux__ */
}
doKlogd(console_log_level);
Modified: trunk/busybox/sysklogd/syslogd.c
===================================================================
--- trunk/busybox/sysklogd/syslogd.c 2006-04-12 17:55:51 UTC (rev 14833)
+++ trunk/busybox/sysklogd/syslogd.c 2006-04-12 18:09:26 UTC (rev 14834)
@@ -673,8 +673,7 @@
#if defined(__uClinux__)
vfork_daemon_rexec(0, 1, argc, argv, "-n");
#else /* __uClinux__ */
- if(daemon(0, 1) < 0)
- bb_perror_msg_and_die("daemon");
+ bb_xdaemon(0, 1);
#endif /* __uClinux__ */
}
doSyslogd();
More information about the busybox-cvs
mailing list