runit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 6979d531adb95c114f5cbb93b7222c3c0dfb6e10
parent af44b352d720ba6e4be9572daacb62796bcb1aa0
Author: Gerrit Pape <pape@smarden.org>
Date:   Tue, 24 Sep 2002 15:03:32 +0000

minor.

Diffstat:
Msrc/runsvdir.c | 16++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/runsvdir.c b/src/runsvdir.c @@ -80,7 +80,7 @@ void runsvdir() { int i; struct stat s; - if (! (dir =opendir(svdir))) { + if (! (dir =opendir("."))) { warn("unable to open directory ", svdir); return; } @@ -162,6 +162,7 @@ int main(int argc, char **argv) { struct stat s; time_t mtime =0; int wstat; + int curdir; int pid; struct taia deadline; struct taia now; @@ -179,7 +180,8 @@ int main(int argc, char **argv) { warn3x("log service disabled.", 0, 0); } } - + if ((curdir =open_read(".")) == -1) + fatal("unable to open current directory", 0); for (;;) { /* collect children */ @@ -194,12 +196,18 @@ int main(int argc, char **argv) { } } } - if (stat(".", &s) != -1) { + if (stat(svdir, &s) != -1) { if (check || s.st_mtime > mtime) { /* svdir modified */ mtime =s.st_mtime; check =0; - runsvdir(); + if (chdir(svdir) == -1) + warn("unable to change directory to", svdir); + else { + runsvdir(); + if (fchdir(curdir) == -1) + warn("unable to change directory", 0); + } } } else