diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-01-27 22:21:52 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-01-27 22:21:52 +0000 |
commit | 05b12d9661ff6a4f0181b971cd6c73b5797a9299 (patch) | |
tree | 4aa5cb8737ab74799096cb8560180890aa2bb5d7 /runit/sv.c | |
parent | c6bbd895662dff96ca89c577623e8f1c234b015f (diff) | |
download | busybox-w32-05b12d9661ff6a4f0181b971cd6c73b5797a9299.tar.gz busybox-w32-05b12d9661ff6a4f0181b971cd6c73b5797a9299.tar.bz2 busybox-w32-05b12d9661ff6a4f0181b971cd6c73b5797a9299.zip |
runit cleanup part 1
git-svn-id: svn://busybox.net/trunk/busybox@17558 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'runit/sv.c')
-rw-r--r-- | runit/sv.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/runit/sv.c b/runit/sv.c index 054053619..6594e1451 100644 --- a/runit/sv.c +++ b/runit/sv.c | |||
@@ -326,28 +326,38 @@ int sv_main(int argc, char **argv) | |||
326 | service++; | 326 | service++; |
327 | } | 327 | } |
328 | 328 | ||
329 | if (*cbk) | 329 | if (*cbk) { |
330 | for (;;) { | 330 | for (;;) { |
331 | //TODO: tdiff resolution is way too high. seconds will be enough | ||
331 | taia_sub(&tdiff, &tnow, &tstart); | 332 | taia_sub(&tdiff, &tnow, &tstart); |
332 | service = servicex; want_exit = 1; | 333 | service = servicex; want_exit = 1; |
333 | for (i = 0; i < services; ++i, ++service) { | 334 | for (i = 0; i < services; ++i, ++service) { |
334 | if (!*service) continue; | 335 | if (!*service) |
336 | continue; | ||
335 | if ((**service != '/') && (**service != '.')) { | 337 | if ((**service != '/') && (**service != '.')) { |
336 | if ((chdir(varservice) == -1) || (chdir(*service) == -1)) { | 338 | if (chdir(varservice) == -1) |
337 | fail("cannot change to service directory"); | 339 | goto chdir_failed; |
338 | *service = 0; | 340 | } |
339 | } | 341 | if (chdir(*service) == -1) { |
340 | } else if (chdir(*service) == -1) { | 342 | chdir_failed: |
341 | fail("cannot change to service directory"); | 343 | fail("cannot change to service directory"); |
342 | *service = 0; | 344 | goto nullify_service; |
343 | } | 345 | } |
344 | if (*service) { if (cbk(acts) != 0) *service = 0; else want_exit = 0; } | 346 | if (cbk(acts) != 0) |
345 | if (*service && taia_approx(&tdiff) > waitsec) { | 347 | goto nullify_service; |
348 | want_exit = 0; | ||
349 | //if (taia_approx(&tdiff) > waitsec) | ||
350 | if (tdiff.sec.x >= waitsec) { | ||
346 | kll ? printf(KILL) : printf(TIMEOUT); | 351 | kll ? printf(KILL) : printf(TIMEOUT); |
347 | if (svstatus_get() > 0) { svstatus_print(*service); ++rc; } | 352 | if (svstatus_get() > 0) { |
353 | svstatus_print(*service); | ||
354 | ++rc; | ||
355 | } | ||
348 | puts(""); /* will also flush the output */ | 356 | puts(""); /* will also flush the output */ |
349 | if (kll) control("k"); | 357 | if (kll) |
350 | *service = 0; | 358 | control("k"); |
359 | nullify_service: | ||
360 | *service = NULL; | ||
351 | } | 361 | } |
352 | if (fchdir(curdir) == -1) | 362 | if (fchdir(curdir) == -1) |
353 | fatal_cannot("change to original directory"); | 363 | fatal_cannot("change to original directory"); |
@@ -356,5 +366,6 @@ int sv_main(int argc, char **argv) | |||
356 | usleep(420000); | 366 | usleep(420000); |
357 | taia_now(&tnow); | 367 | taia_now(&tnow); |
358 | } | 368 | } |
369 | } | ||
359 | return rc > 99 ? 99 : rc; | 370 | return rc > 99 ? 99 : rc; |
360 | } | 371 | } |