Hello, I wrote a patch for how broken filedescriptors when creating child are handled. Currently only the child dies, leaving non-working instance of runsv in place. My patch makes it kill the parent so the runsv process can be respawned properly when it gets to the state in which it can't produce working children.
This should fix the behaviour described in Message-id: CAN_+VLUtc+JBAATN55b2o6G8tmH4Y8OKLCf-yA6maBt+c1=g...@mail.gmail.com http://blog.gmane.org/gmane.comp.sysutils.supervision.general/month=20130301 and Message-id: [email protected] http://blog.gmane.org/gmane.comp.sysutils.supervision.general/month=20100801 --- runsv.c.orig 2014-07-24 16:17:43.087191947 +0200 +++ runsv.c 2014-07-24 18:27:29.720588407 +0200 @@ -62,6 +62,11 @@ void usage () { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); } +void fatal_child(char *m) { + strerr_warn5("runsv ", dir, ": fatal: ", m, ": ", &strerr_sys); + kill(getppid(), SIGTERM); + _exit(111); +} void fatal(char *m) { strerr_die5sys(111, "runsv ", dir, ": fatal: ", m, ": "); } @@ -289,14 +294,14 @@ if (haslog) { if (s->islog) { if (fd_copy(0, logpipe[0]) == -1) - fatal("unable to setup filedescriptor for ./log/run"); + fatal_child("unable to setup filedescriptor for ./log/run"); close(logpipe[1]); if (chdir("./log") == -1) fatal("unable to change directory to ./log"); } else { if (fd_copy(1, logpipe[1]) == -1) - fatal("unable to setup filedescriptor for ./run"); + fatal_child("unable to setup filedescriptor for ./run"); close(logpipe[0]); } }
