diff options
author | Denis Vlasenko | 2007-01-27 22:21:52 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-01-27 22:21:52 +0000 |
commit | 8c7839512039212ba88e48d856d0ac9835fdec67 (patch) | |
tree | 4aa5cb8737ab74799096cb8560180890aa2bb5d7 /runit/sv.c | |
parent | e06bed30cfcde7b9e320aff8a4c878c72416c4c4 (diff) | |
download | busybox-8c7839512039212ba88e48d856d0ac9835fdec67.zip busybox-8c7839512039212ba88e48d856d0ac9835fdec67.tar.gz |
runit cleanup part 1
Diffstat (limited to 'runit/sv.c')
-rw-r--r-- | runit/sv.c | 37 |
1 files changed, 24 insertions, 13 deletions
@@ -326,28 +326,38 @@ int sv_main(int argc, char **argv) service++; } - if (*cbk) + if (*cbk) { for (;;) { +//TODO: tdiff resolution is way too high. seconds will be enough taia_sub(&tdiff, &tnow, &tstart); service = servicex; want_exit = 1; for (i = 0; i < services; ++i, ++service) { - if (!*service) continue; + if (!*service) + continue; if ((**service != '/') && (**service != '.')) { - if ((chdir(varservice) == -1) || (chdir(*service) == -1)) { - fail("cannot change to service directory"); - *service = 0; - } - } else if (chdir(*service) == -1) { + if (chdir(varservice) == -1) + goto chdir_failed; + } + if (chdir(*service) == -1) { + chdir_failed: fail("cannot change to service directory"); - *service = 0; + goto nullify_service; } - if (*service) { if (cbk(acts) != 0) *service = 0; else want_exit = 0; } - if (*service && taia_approx(&tdiff) > waitsec) { + if (cbk(acts) != 0) + goto nullify_service; + want_exit = 0; + //if (taia_approx(&tdiff) > waitsec) + if (tdiff.sec.x >= waitsec) { kll ? printf(KILL) : printf(TIMEOUT); - if (svstatus_get() > 0) { svstatus_print(*service); ++rc; } + if (svstatus_get() > 0) { + svstatus_print(*service); + ++rc; + } puts(""); /* will also flush the output */ - if (kll) control("k"); - *service = 0; + if (kll) + control("k"); + nullify_service: + *service = NULL; } if (fchdir(curdir) == -1) fatal_cannot("change to original directory"); @@ -356,5 +366,6 @@ int sv_main(int argc, char **argv) usleep(420000); taia_now(&tnow); } + } return rc > 99 ? 99 : rc; } |