summaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenis Vlasenko2007-03-26 13:20:54 +0000
committerDenis Vlasenko2007-03-26 13:20:54 +0000
commit5a142025d372ae5dff7d7cf98f442edaafd1dc30 (patch)
tree19d222f7d7040945cf92e239055dfdd00b8656bc /miscutils
parentbb7fcb4229fd5ff583039f26ca1c06340e3f09ea (diff)
downloadbusybox-5a142025d372ae5dff7d7cf98f442edaafd1dc30.zip
busybox-5a142025d372ae5dff7d7cf98f442edaafd1dc30.tar.gz
move everything to new NOMMU helpers, except udhcp
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/crond.c64
-rw-r--r--miscutils/watchdog.c15
2 files changed, 19 insertions, 60 deletions
diff --git a/miscutils/crond.c b/miscutils/crond.c
index 1ab0038..9d511f9 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -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);
diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c
index e3d77d1..28ae9bd 100644
--- a/miscutils/watchdog.c
+++ b/miscutils/watchdog.c
@@ -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; */
}