summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
Diffstat (limited to 'networking')
-rw-r--r--networking/dnsd.c7
-rw-r--r--networking/httpd.c2
-rw-r--r--networking/inetd.c28
-rw-r--r--networking/isrv_identd.c4
-rw-r--r--networking/telnetd.c2
-rw-r--r--networking/zcip.c3
6 files changed, 18 insertions, 28 deletions
diff --git a/networking/dnsd.c b/networking/dnsd.c
index c9c7b3a..8807bbe 100644
--- a/networking/dnsd.c
+++ b/networking/dnsd.c
@@ -353,12 +353,7 @@ int dnsd_main(int argc, char **argv)
}
if (OPT_daemon) {
-#ifdef BB_NOMMU
- if (!re_execed)
- vfork_daemon_rexec(1, 0, argv);
-#else
- xdaemon(1, 0);
-#endif
+ bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, argv);
openlog(applet_name, LOG_PID, LOG_DAEMON);
logmode = LOGMODE_SYSLOG;
}
diff --git a/networking/httpd.c b/networking/httpd.c
index 72b03de..b8d9b6b 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -2044,6 +2044,6 @@ int httpd_main(int argc, char *argv[])
return miniHttpd_inetd();
if (!(opt & OPT_FOREGROUND))
- xdaemon(1, 0); /* don't change current directory */
+ bb_daemonize(0); /* don't change current directory */
return miniHttpd(config->server_socket);
}
diff --git a/networking/inetd.c b/networking/inetd.c
index 8312346..4faa420 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -1274,30 +1274,24 @@ int inetd_main(int argc, char *argv[])
LastArg = envp[-1] + strlen(envp[-1]);
#endif
- opt = getopt32(argc, argv, "R:f", &stoomany);
- if(opt & 1) {
- toomany = xatoi_u(stoomany);
- }
- argc -= optind;
- argv += optind;
-
uid = getuid();
if (uid != 0)
config_filename = NULL;
- if (argc > 0)
+
+ opt = getopt32(argc, argv, "R:f", &stoomany);
+ if (opt & 1)
+ toomany = xatoi_u(stoomany);
+ argv += optind;
+ argc -= optind;
+ if (argc)
config_filename = argv[0];
if (config_filename == NULL)
bb_error_msg_and_die("non-root must specify a config file");
-#ifdef BB_NOMMU
- if (!(opt & 2)) {
- if (!re_execed)
- vfork_daemon_rexec(0, 0, argv);
- }
- bb_sanitize_stdio();
-#else
- bb_sanitize_stdio_maybe_daemonize(!(opt & 2));
-#endif
+ if (!(opt & 2))
+ bb_daemonize_or_rexec(0, argv - optind);
+ else
+ bb_sanitize_stdio();
openlog(applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
logmode = LOGMODE_SYSLOG;
diff --git a/networking/isrv_identd.c b/networking/isrv_identd.c
index f9ab0b2..c230c7e 100644
--- a/networking/isrv_identd.c
+++ b/networking/isrv_identd.c
@@ -112,7 +112,9 @@ int fakeidentd_main(int argc, char **argv)
bogouser = argv[optind];
/* Daemonize if no -f and no -i and no -w */
- bb_sanitize_stdio_maybe_daemonize(!(opt & OPT_fiw));
+ if (!(opt & OPT_fiw));
+ bb_daemonize_or_rexec(0, argv);
+
/* Where to log in inetd modes? "Classic" inetd
* probably has its stderr /dev/null'ed (we need log to syslog?),
* but daemontools-like utilities usually expect that children
diff --git a/networking/telnetd.c b/networking/telnetd.c
index ef9b1ac..5c0463b 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -415,7 +415,7 @@ int telnetd_main(int argc, char **argv)
master_fd = create_and_bind_stream_or_die(opt_bindaddr, portnbr);
xlisten(master_fd, 1);
if (!(opt & OPT_FOREGROUND))
- xdaemon(0, 0);
+ bb_daemonize(DAEMON_CHDIR_ROOT);
}
#else
sessions = make_new_session();
diff --git a/networking/zcip.c b/networking/zcip.c
index c50d5ab..c0cf665 100644
--- a/networking/zcip.c
+++ b/networking/zcip.c
@@ -271,9 +271,8 @@ int zcip_main(int argc, char *argv[])
// daemonize now; don't delay system startup
if (!FOREGROUND) {
- /* bb_daemonize(); - bad, will close fd! */
//NOMMU
- xdaemon(0, 0);
+ bb_daemonize(DAEMON_CHDIR_ROOT);
bb_info_msg("start, interface %s", intf);
}