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/crond.c | |
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/crond.c')
-rw-r--r-- | miscutils/crond.c | 64 |
1 files changed, 16 insertions, 48 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 | ||