diff options
author | Gerrit Pape <pape@smarden.org> | 2003-01-24 14:18:11 +0000 |
---|---|---|
committer | Gerrit Pape <pape@smarden.org> | 2003-01-24 14:18:11 +0000 |
commit | 3bc722193d7b59c78dc15c723b747919b093828d (patch) | |
tree | 2220a941aca32ffbfb7ca44cee8d4b94dc1fb0f4 /src/runsv.c | |
parent | 66db52c8b65bbecf38c15db7222fc9a6eede601c (diff) | |
download | runit-3bc722193d7b59c78dc15c723b747919b093828d.tar.gz runit-3bc722193d7b59c78dc15c723b747919b093828d.tar.xz runit-3bc722193d7b59c78dc15c723b747919b093828d.zip |
* runsv.c: close finish script file descriptor.
* runsv.c: close logpipe[] instead of sending sigterm to logservice when told to exit, loggers should exit when they see EOF on stdin (thx Paul Jarc). * etc/*/1, etc/*/3: remove explicit 'exit'. * error.h: include <errno.h> (upcoming glibc changes). 0.8.2.
Diffstat (limited to 'src/runsv.c')
-rw-r--r-- | src/runsv.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/runsv.c b/src/runsv.c index afdf094..fad407a 100644 --- a/src/runsv.c +++ b/src/runsv.c @@ -214,7 +214,7 @@ void stopservice(struct svdir *s) { void startservice(struct svdir *s) { int p; char *run[2]; - + if (s->state == S_FINISH) run[0] ="./finish"; else @@ -232,12 +232,14 @@ void startservice(struct svdir *s) { if (s->islog) { if (fd_copy(0, logpipe[0]) == -1) fatal("unable to setup filedescriptor for ./log/run"); + close(logpipe[1]); if (chdir("./log") == -1) - fatal("unable to change directory ./log"); + fatal("unable to change directory to ./log"); } else { if (fd_copy(1, logpipe[1]) == -1) fatal("unable to setup filedescriptor for ./run"); + close(logpipe[0]); } } sig_uncatch(sig_child); @@ -349,6 +351,7 @@ int main(int argc, char **argv) { svd[0].ctrl =C_NOOP; svd[0].want =W_UP; svd[0].islog =0; + svd[1].pid =0; taia_now(&svd[0].start); if (stat("down", &s) != -1) svd[0].want =W_DOWN; @@ -362,7 +365,6 @@ int main(int argc, char **argv) { warnx("./log: not a directory."); else { haslog =1; - svd[1].pid =0; svd[1].state =S_DOWN; svd[1].ctrl =C_NOOP; svd[1].want =W_UP; @@ -458,12 +460,14 @@ int main(int argc, char **argv) { if (child == svd[0].pid) { svd[0].pid =0; pidchanged =1; - if ((svd[0].state != S_FINISH) && (open_read("finish") != -1)) { - svd[0].state =S_FINISH; - startservice(&svd[0]); - update_status(&svd[0]); - break; - } + if (svd[0].state != S_FINISH) + if ((fd =open_read("finish")) != -1) { + close(fd); + svd[0].state =S_FINISH; + startservice(&svd[0]); + update_status(&svd[0]); + break; + } svd[0].state =S_DOWN; svd[0].ctrl &=~C_TERM; taia_now(&svd[0].start); @@ -499,7 +503,12 @@ int main(int argc, char **argv) { exit(0); if (svd[1].want != W_EXIT) { svd[1].want =W_EXIT; + /* stopservice(&svd[1]); + */ + update_status(&svd[1]); + if (close(logpipe[1]) == -1) warn("unable to close logpipe[1]"); + if (close(logpipe[0]) == -1) warn("unable to close logpipe[0]"); } } } |