diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-26 13:20:54 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-26 13:20:54 +0000 |
| commit | 5a142025d372ae5dff7d7cf98f442edaafd1dc30 (patch) | |
| tree | 19d222f7d7040945cf92e239055dfdd00b8656bc /miscutils | |
| parent | bb7fcb4229fd5ff583039f26ca1c06340e3f09ea (diff) | |
| download | busybox-w32-5a142025d372ae5dff7d7cf98f442edaafd1dc30.tar.gz busybox-w32-5a142025d372ae5dff7d7cf98f442edaafd1dc30.tar.bz2 busybox-w32-5a142025d372ae5dff7d7cf98f442edaafd1dc30.zip | |
move everything to new NOMMU helpers, except udhcp
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/crond.c | 64 | ||||
| -rw-r--r-- | miscutils/watchdog.c | 15 |
2 files changed, 19 insertions, 60 deletions
diff --git a/miscutils/crond.c b/miscutils/crond.c index 1ab0038e0..9d511f960 100644 --- a/miscutils/crond.c +++ b/miscutils/crond.c | |||
| @@ -136,75 +136,43 @@ int crond_main(int ac, char **av) | |||
| 136 | { | 136 | { |
| 137 | unsigned opt; | 137 | unsigned opt; |
| 138 | char *lopt, *Lopt, *copt; | 138 | char *lopt, *Lopt, *copt; |
| 139 | USE_DEBUG_CROND_OPTION(char *dopt;) | ||
| 139 | 140 | ||
| 140 | #if ENABLE_DEBUG_CROND_OPTION | 141 | opt_complementary = "f-b:b-f:S-L:L-S" USE_DEBUG_CROND_OPTION(":d-l"); |
| 141 | char *dopt; | ||
| 142 | |||
| 143 | opt_complementary = "f-b:b-f:S-L:L-S:d-l"; | ||
| 144 | #else | ||
| 145 | opt_complementary = "f-b:b-f:S-L:L-S"; | ||
| 146 | #endif | ||
| 147 | |||
| 148 | opterr = 0; /* disable getopt 'errors' message. */ | 142 | opterr = 0; /* disable getopt 'errors' message. */ |
| 149 | opt = getopt32(ac, av, "l:L:fbSc:" | 143 | opt = getopt32(ac, av, "l:L:fbSc:" USE_DEBUG_CROND_OPTION("d:"), |
| 150 | #if ENABLE_DEBUG_CROND_OPTION | 144 | &lopt, &Lopt, &copt USE_DEBUG_CROND_OPTION(, &dopt)); |
| 151 | "d:" | 145 | if (opt & 1) /* -l */ |
| 152 | #endif | ||
| 153 | , &lopt, &Lopt, &copt | ||
| 154 | #if ENABLE_DEBUG_CROND_OPTION | ||
| 155 | , &dopt | ||
| 156 | #endif | ||
| 157 | ); | ||
| 158 | if (opt & 1) { | ||
| 159 | LogLevel = xatou(lopt); | 146 | LogLevel = xatou(lopt); |
| 160 | } | 147 | if (opt & 2) /* -L */ |
| 161 | if (opt & 2) { | 148 | if (*Lopt) |
| 162 | if (*Lopt != 0) { | ||
| 163 | LogFile = Lopt; | 149 | LogFile = Lopt; |
| 164 | } | 150 | if (opt & 32) /* -c */ |
| 165 | } | 151 | if (*copt) |
| 166 | if (opt & 32) { | ||
| 167 | if (*copt != 0) { | ||
| 168 | CDir = copt; | 152 | CDir = copt; |
| 169 | } | ||
| 170 | } | ||
| 171 | #if ENABLE_DEBUG_CROND_OPTION | 153 | #if ENABLE_DEBUG_CROND_OPTION |
| 172 | if (opt & 64) { | 154 | if (opt & 64) { /* -d */ |
| 173 | DebugOpt = xatou(dopt); | 155 | DebugOpt = xatou(dopt); |
| 174 | LogLevel = 0; | 156 | LogLevel = 0; |
| 175 | } | 157 | } |
| 176 | #endif | 158 | #endif |
| 177 | 159 | ||
| 178 | /* | 160 | /* close stdin and stdout, stderr. |
| 179 | * change directory | ||
| 180 | */ | ||
| 181 | |||
| 182 | xchdir(CDir); | ||
| 183 | signal(SIGHUP, SIG_IGN); /* hmm.. but, if kill -HUP original | ||
| 184 | * version - his died. ;( | ||
| 185 | */ | ||
| 186 | /* | ||
| 187 | * close stdin and stdout, stderr. | ||
| 188 | * close unused descriptors - don't need. | 161 | * close unused descriptors - don't need. |
| 189 | * optional detach from controlling terminal | 162 | * optional detach from controlling terminal |
| 190 | */ | 163 | */ |
| 164 | if (!(opt & 4)) | ||
| 165 | bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, av); | ||
| 191 | 166 | ||
| 192 | if (!(opt & 4)) { | 167 | xchdir(CDir); |
| 193 | #ifdef BB_NOMMU | 168 | signal(SIGHUP, SIG_IGN); /* ? original crond dies on HUP... */ |
| 194 | if (!re_execed) | ||
| 195 | vfork_daemon_rexec(1, 0, av); | ||
| 196 | #else | ||
| 197 | xdaemon(1, 0); | ||
| 198 | #endif | ||
| 199 | } | ||
| 200 | 169 | ||
| 201 | (void) startlogger(); /* need if syslog mode selected */ | 170 | startlogger(); /* need if syslog mode selected */ |
| 202 | 171 | ||
| 203 | /* | 172 | /* |
| 204 | * main loop - synchronize to 1 second after the minute, minimum sleep | 173 | * main loop - synchronize to 1 second after the minute, minimum sleep |
| 205 | * of 1 second. | 174 | * of 1 second. |
| 206 | */ | 175 | */ |
| 207 | |||
| 208 | crondlog("\011%s " VERSION " dillon, started, log level %d\n", | 176 | crondlog("\011%s " VERSION " dillon, started, log level %d\n", |
| 209 | applet_name, LogLevel); | 177 | applet_name, LogLevel); |
| 210 | 178 | ||
diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c index e3d77d17e..28ae9bdb0 100644 --- a/miscutils/watchdog.c +++ b/miscutils/watchdog.c | |||
| @@ -29,29 +29,21 @@ int watchdog_main(int argc, char **argv) | |||
| 29 | unsigned timer_duration = 30; /* Userspace timer duration, in seconds */ | 29 | unsigned timer_duration = 30; /* Userspace timer duration, in seconds */ |
| 30 | char *t_arg; | 30 | char *t_arg; |
| 31 | 31 | ||
| 32 | opt_complementary = "=1"; /* must have 1 argument */ | ||
| 32 | opts = getopt32(argc, argv, "Ft:", &t_arg); | 33 | opts = getopt32(argc, argv, "Ft:", &t_arg); |
| 33 | 34 | ||
| 34 | if (opts & OPT_TIMER) | 35 | if (opts & OPT_TIMER) |
| 35 | timer_duration = xatou(t_arg); | 36 | timer_duration = xatou(t_arg); |
| 36 | 37 | ||
| 37 | /* We're only interested in the watchdog device .. */ | ||
| 38 | if (optind < argc - 1 || argc == 1) | ||
| 39 | bb_show_usage(); | ||
| 40 | |||
| 41 | if (!(opts & OPT_FOREGROUND)) { | 38 | if (!(opts & OPT_FOREGROUND)) { |
| 42 | #ifdef BB_NOMMU | 39 | bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv); |
| 43 | if (!re_execed) | ||
| 44 | vfork_daemon_rexec(0, 1, argv); | ||
| 45 | #else | ||
| 46 | xdaemon(0, 1); | ||
| 47 | #endif | ||
| 48 | } | 40 | } |
| 49 | 41 | ||
| 50 | signal(SIGHUP, watchdog_shutdown); | 42 | signal(SIGHUP, watchdog_shutdown); |
| 51 | signal(SIGINT, watchdog_shutdown); | 43 | signal(SIGINT, watchdog_shutdown); |
| 52 | 44 | ||
| 53 | /* Use known fd # - avoid needing global 'int fd' */ | 45 | /* Use known fd # - avoid needing global 'int fd' */ |
| 54 | dup2(xopen(argv[argc - 1], O_WRONLY), 3); | 46 | xmove_fd(xopen(argv[argc - 1], O_WRONLY), 3); |
| 55 | 47 | ||
| 56 | while (1) { | 48 | while (1) { |
| 57 | /* | 49 | /* |
| @@ -63,6 +55,5 @@ int watchdog_main(int argc, char **argv) | |||
| 63 | } | 55 | } |
| 64 | 56 | ||
| 65 | watchdog_shutdown(0); | 57 | watchdog_shutdown(0); |
| 66 | |||
| 67 | /* return EXIT_SUCCESS; */ | 58 | /* return EXIT_SUCCESS; */ |
| 68 | } | 59 | } |
