mirror of
https://git.busybox.net/busybox.git
synced 2024-11-27 15:43:26 +08:00
move everything to new NOMMU helpers, except udhcp
This commit is contained in:
parent
bb7fcb4229
commit
5a142025d3
@ -299,8 +299,7 @@ int start_stop_daemon_main(int argc, char **argv)
|
||||
}
|
||||
*--argv = startas;
|
||||
if (opt & OPT_BACKGROUND) {
|
||||
setsid();
|
||||
bb_daemonize();
|
||||
bb_daemonize(0);
|
||||
}
|
||||
if (opt & OPT_MAKEPID) {
|
||||
/* user wants _us_ to make the pidfile */
|
||||
|
@ -136,75 +136,43 @@ int crond_main(int ac, char **av)
|
||||
{
|
||||
unsigned opt;
|
||||
char *lopt, *Lopt, *copt;
|
||||
USE_DEBUG_CROND_OPTION(char *dopt;)
|
||||
|
||||
#if ENABLE_DEBUG_CROND_OPTION
|
||||
char *dopt;
|
||||
|
||||
opt_complementary = "f-b:b-f:S-L:L-S:d-l";
|
||||
#else
|
||||
opt_complementary = "f-b:b-f:S-L:L-S";
|
||||
#endif
|
||||
|
||||
opt_complementary = "f-b:b-f:S-L:L-S" USE_DEBUG_CROND_OPTION(":d-l");
|
||||
opterr = 0; /* disable getopt 'errors' message. */
|
||||
opt = getopt32(ac, av, "l:L:fbSc:"
|
||||
#if ENABLE_DEBUG_CROND_OPTION
|
||||
"d:"
|
||||
#endif
|
||||
, &lopt, &Lopt, &copt
|
||||
#if ENABLE_DEBUG_CROND_OPTION
|
||||
, &dopt
|
||||
#endif
|
||||
);
|
||||
if (opt & 1) {
|
||||
opt = getopt32(ac, av, "l:L:fbSc:" USE_DEBUG_CROND_OPTION("d:"),
|
||||
&lopt, &Lopt, &copt USE_DEBUG_CROND_OPTION(, &dopt));
|
||||
if (opt & 1) /* -l */
|
||||
LogLevel = xatou(lopt);
|
||||
}
|
||||
if (opt & 2) {
|
||||
if (*Lopt != 0) {
|
||||
if (opt & 2) /* -L */
|
||||
if (*Lopt)
|
||||
LogFile = Lopt;
|
||||
}
|
||||
}
|
||||
if (opt & 32) {
|
||||
if (*copt != 0) {
|
||||
if (opt & 32) /* -c */
|
||||
if (*copt)
|
||||
CDir = copt;
|
||||
}
|
||||
}
|
||||
#if ENABLE_DEBUG_CROND_OPTION
|
||||
if (opt & 64) {
|
||||
if (opt & 64) { /* -d */
|
||||
DebugOpt = xatou(dopt);
|
||||
LogLevel = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* change directory
|
||||
*/
|
||||
|
||||
xchdir(CDir);
|
||||
signal(SIGHUP, SIG_IGN); /* hmm.. but, if kill -HUP original
|
||||
* version - his died. ;(
|
||||
*/
|
||||
/*
|
||||
* close stdin and stdout, stderr.
|
||||
/* close stdin and stdout, stderr.
|
||||
* close unused descriptors - don't need.
|
||||
* optional detach from controlling terminal
|
||||
*/
|
||||
if (!(opt & 4))
|
||||
bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, av);
|
||||
|
||||
if (!(opt & 4)) {
|
||||
#ifdef BB_NOMMU
|
||||
if (!re_execed)
|
||||
vfork_daemon_rexec(1, 0, av);
|
||||
#else
|
||||
xdaemon(1, 0);
|
||||
#endif
|
||||
}
|
||||
xchdir(CDir);
|
||||
signal(SIGHUP, SIG_IGN); /* ? original crond dies on HUP... */
|
||||
|
||||
(void) startlogger(); /* need if syslog mode selected */
|
||||
startlogger(); /* need if syslog mode selected */
|
||||
|
||||
/*
|
||||
* main loop - synchronize to 1 second after the minute, minimum sleep
|
||||
* of 1 second.
|
||||
*/
|
||||
|
||||
crondlog("\011%s " VERSION " dillon, started, log level %d\n",
|
||||
applet_name, LogLevel);
|
||||
|
||||
|
@ -29,29 +29,21 @@ int watchdog_main(int argc, char **argv)
|
||||
unsigned timer_duration = 30; /* Userspace timer duration, in seconds */
|
||||
char *t_arg;
|
||||
|
||||
opt_complementary = "=1"; /* must have 1 argument */
|
||||
opts = getopt32(argc, argv, "Ft:", &t_arg);
|
||||
|
||||
if (opts & OPT_TIMER)
|
||||
timer_duration = xatou(t_arg);
|
||||
|
||||
/* We're only interested in the watchdog device .. */
|
||||
if (optind < argc - 1 || argc == 1)
|
||||
bb_show_usage();
|
||||
|
||||
if (!(opts & OPT_FOREGROUND)) {
|
||||
#ifdef BB_NOMMU
|
||||
if (!re_execed)
|
||||
vfork_daemon_rexec(0, 1, argv);
|
||||
#else
|
||||
xdaemon(0, 1);
|
||||
#endif
|
||||
bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv);
|
||||
}
|
||||
|
||||
signal(SIGHUP, watchdog_shutdown);
|
||||
signal(SIGINT, watchdog_shutdown);
|
||||
|
||||
/* Use known fd # - avoid needing global 'int fd' */
|
||||
dup2(xopen(argv[argc - 1], O_WRONLY), 3);
|
||||
xmove_fd(xopen(argv[argc - 1], O_WRONLY), 3);
|
||||
|
||||
while (1) {
|
||||
/*
|
||||
@ -63,6 +55,5 @@ int watchdog_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
watchdog_shutdown(0);
|
||||
|
||||
/* return EXIT_SUCCESS; */
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
if (!(opt & 2))
|
||||
bb_daemonize_or_rexec(0, argv - optind);
|
||||
else
|
||||
bb_sanitize_stdio();
|
||||
#else
|
||||
bb_sanitize_stdio_maybe_daemonize(!(opt & 2));
|
||||
#endif
|
||||
openlog(applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
|
||||
logmode = LOGMODE_SYSLOG;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -50,12 +50,7 @@ int klogd_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!(option_mask32 & OPT_FOREGROUND)) {
|
||||
#ifdef BB_NOMMU
|
||||
if (!re_execed)
|
||||
vfork_daemon_rexec(0, 1, argv);
|
||||
#else
|
||||
bb_daemonize();
|
||||
#endif
|
||||
bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv);
|
||||
}
|
||||
|
||||
openlog("kernel", 0, LOG_KERN);
|
||||
|
@ -642,12 +642,7 @@ int syslogd_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!(option_mask32 & OPT_nofork)) {
|
||||
#ifdef BB_NOMMU
|
||||
if (!re_execed)
|
||||
vfork_daemon_rexec(0, 1, argv);
|
||||
#else
|
||||
bb_daemonize();
|
||||
#endif
|
||||
bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv);
|
||||
}
|
||||
umask(0);
|
||||
do_syslogd();
|
||||
|
Loading…
Reference in New Issue
Block a user