summary refs log tree commit diff
path: root/src/runsvdir.c
diff options
context:
space:
mode:
authorGerrit Pape <pape@smarden.org>2004-09-21 18:08:37 +0000
committerGerrit Pape <pape@smarden.org>2004-09-21 18:08:37 +0000
commitb23a59b512c26497755ab68ba9fd464cf574a5f3 (patch)
tree200eef2a79040b98696fd01750add52a616eaacc /src/runsvdir.c
parentf0f2b280c58a5ce85c9e3cb3a581ca6b0bc70105 (diff)
downloadrunit-b23a59b512c26497755ab68ba9fd464cf574a5f3.tar.gz
runit-b23a59b512c26497755ab68ba9fd464cf574a5f3.tar.xz
runit-b23a59b512c26497755ab68ba9fd464cf574a5f3.zip
* runsvdir.c: new option -P, run each runsv process in a new session and
    process group (thx Charlie Brady).
  * man/runsvdir.8: adapt; typo.
Diffstat (limited to 'src/runsvdir.c')
-rw-r--r--src/runsvdir.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/runsvdir.c b/src/runsvdir.c
index 2faa3df..27aef7f 100644
--- a/src/runsvdir.c
+++ b/src/runsvdir.c
@@ -16,7 +16,7 @@
 #include "sig.h"
 #include "ndelay.h"
 
-#define USAGE " dir"
+#define USAGE " [-P] dir"
 #define VERSION "$Id$"
 
 #define MAXSERVICES 1000
@@ -39,6 +39,7 @@ int logpipe[2];
 iopause_fd io[1];
 struct taia stamplog;
 int exitsoon =0;
+int pgrp =0;
 
 void usage () { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); }
 void fatal(char *m1, char *m2) {
@@ -72,6 +73,7 @@ void runsv(int no, char *name) {
 	warn("unable to set filedescriptor for log service", 0);
     sig_uncatch(sig_hangup);
     sig_uncatch(sig_term);
+    if (pgrp) setsid();
     pathexec_run(*prog, prog, (const char* const*)environ);
     fatal("unable to start runsv ", name);
   }
@@ -174,6 +176,13 @@ int main(int argc, char **argv) {
 
   progname =*argv++;
   if (! argv || ! *argv) usage();
+  if (**argv == '-') {
+    switch (*(*argv +1)) {
+    case 'P': pgrp =1;
+    case '-': ++argv;
+    }
+    if (! argv || ! *argv) usage();
+  }
 
   sig_catch(sig_term, s_term);
   sig_catch(sig_hangup, s_hangup);