diff options
author | Gerrit Pape <pape@smarden.org> | 2004-08-02 14:03:01 +0000 |
---|---|---|
committer | Gerrit Pape <pape@smarden.org> | 2004-08-02 14:03:01 +0000 |
commit | dad0416beacc6cf75c21eb6f5359532c064882a6 (patch) | |
tree | 830f03f8a4d6469ef81d600851f1def41e92d70b /src | |
parent | b90e7716cf8022bfc0e8b4bd49b9bcb08934438e (diff) | |
download | runit-dad0416beacc6cf75c21eb6f5359532c064882a6.tar.gz runit-dad0416beacc6cf75c21eb6f5359532c064882a6.tar.xz runit-dad0416beacc6cf75c21eb6f5359532c064882a6.zip |
* runsvdir.c:
sleep one second before scanning if services dir mtime is now; loop while chdir to starting dir fails; rename log, loglen to rplog, rploglen. * etc/macosx/StartupItems/runit: use -x option to svwaitdown; timeout 14.
Diffstat (limited to 'src')
-rw-r--r-- | src/runsvdir.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/runsvdir.c b/src/runsvdir.c index 8927dd0..2faa3df 100644 --- a/src/runsvdir.c +++ b/src/runsvdir.c @@ -33,8 +33,8 @@ struct { } sv[MAXSERVICES]; int svnum =0; int check =1; -char *log =0; -int loglen; +char *rplog =0; +int rploglen; int logpipe[2]; iopause_fd io[1]; struct taia stamplog; @@ -67,7 +67,7 @@ void runsv(int no, char *name) { prog[0] ="runsv"; prog[1] =name; prog[2] =0; - if (log) + if (rplog) if (fd_move(2, logpipe[1]) == -1) warn("unable to set filedescriptor for log service", 0); sig_uncatch(sig_hangup); @@ -138,7 +138,7 @@ void runsvdir() { } int setup_log() { - if ((loglen =str_len(log)) < 7) { + if ((rploglen =str_len(rplog)) < 7) { warn3x("log must have at least seven characters.", 0, 0); return(0); } @@ -179,9 +179,9 @@ int main(int argc, char **argv) { sig_catch(sig_hangup, s_hangup); svdir =*argv++; if (argv && *argv) { - log =*argv; + rplog =*argv; if (setup_log() != 1) { - log =0; + rplog =0; warn3x("log service disabled.", 0, 0); } } @@ -211,7 +211,7 @@ int main(int argc, char **argv) { warn3x("time warp: resetting time stamp.", 0, 0); taia_now(&stampcheck); taia_now(&now); - if (log) taia_now(&stamplog); + if (rplog) taia_now(&stamplog); } if (taia_less(&now, &stampcheck) == 0) { /* wait at least a second */ @@ -227,6 +227,8 @@ int main(int argc, char **argv) { dev =s.st_dev; ino =s.st_ino; check =0; + if (now.sec.x <= (4611686018427387914ULL +(uint64)mtime)) + sleep(1); runsvdir(); while (fchdir(curdir) == -1) { warn("unable to change directory, pausing", 0); @@ -241,7 +243,7 @@ int main(int argc, char **argv) { warn("unable to stat ", svdir); } - if (log) + if (rplog) if (taia_less(&now, &stamplog) == 0) { write(logpipe[1], ".", 1); taia_uint(&deadline, 900); @@ -251,20 +253,20 @@ int main(int argc, char **argv) { taia_add(&deadline, &now, &deadline); sig_block(sig_child); - if (log) + if (rplog) iopause(io, 1, &deadline, &now); else iopause(0, 0, &deadline, &now); sig_unblock(sig_child); - if (log && (io[0].revents | IOPAUSE_READ)) - while (read(logpipe[0], &ch, 1) > 0) { + if (rplog && (io[0].revents | IOPAUSE_READ)) + while (read(logpipe[0], &ch, 1) > 0) if (ch) { - for (i =6; i < loglen; i++) - log[i -1] =log[i]; - log[loglen -1] =ch; + for (i =6; i < rploglen; i++) + rplog[i -1] =rplog[i]; + rplog[rploglen -1] =ch; } - } + switch(exitsoon) { case 1: _exit(0); |