summaryrefslogtreecommitdiff
path: root/runit/sv.c
diff options
context:
space:
mode:
authorDenis Vlasenko2007-01-27 22:21:52 +0000
committerDenis Vlasenko2007-01-27 22:21:52 +0000
commit8c7839512039212ba88e48d856d0ac9835fdec67 (patch)
tree4aa5cb8737ab74799096cb8560180890aa2bb5d7 /runit/sv.c
parente06bed30cfcde7b9e320aff8a4c878c72416c4c4 (diff)
downloadbusybox-8c7839512039212ba88e48d856d0ac9835fdec67.zip
busybox-8c7839512039212ba88e48d856d0ac9835fdec67.tar.gz
runit cleanup part 1
Diffstat (limited to 'runit/sv.c')
-rw-r--r--runit/sv.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/runit/sv.c b/runit/sv.c
index 0540536..6594e14 100644
--- a/runit/sv.c
+++ b/runit/sv.c
@@ -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;
}