Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a killpg flag file #23

Open
josb opened this issue Oct 1, 2014 · 0 comments
Open

Add a killpg flag file #23

josb opened this issue Oct 1, 2014 · 0 comments

Comments

@josb
Copy link

josb commented Oct 1, 2014

How about a supervise flag file named 'killpg' that causes svc to default to sending a signal to the service process group by default? This would only be set for processes that do not clean up their children properly.

Initial patch below. This is largely inspired by the no-setsid change but it splits this feature off into its own flag, because they are orthogonal ideas.

--- a/supervise.8.in
+++ b/supervise.8.in
@@ -40,6 +40,12 @@ exists,
 .B supervise
 will run subordinate processes in a new process group.

+If the file
+.B ./killpg
+exists, all signals requested by the
+.BR svc (8)
+program will be sent to the process group instead of the process.
+
 If
 .B ./log
 is an executable file,
diff --git a/supervise.c b/supervise.c
index a792f66..e4f21c8 100644
--- a/supervise.c
+++ b/supervise.c
@@ -326,6 +326,7 @@ void doit(void)

     svc = &svcmain;
     killpid = svc->pid;
+    if (stat_exists("killpg")==0) killpid = -killpid;
     while (read(fdcontrol,&ch,1) == 1)
       switch(ch) {
       case '+':
@@ -340,6 +341,7 @@ void doit(void)
       break;
       case 'l':
       svc = &svcmain;
 +     if (stat_exists("killpg")==0) killpid = -killpid;
       killpid = svc->pid;
       break;
       case 'd':
diff --git a/svc.8.in b/svc.8.in
index 8e2e2b6..582821e 100644
--- a/svc.8.in
+++ b/svc.8.in
@@ -25,7 +25,10 @@ process group. This is the default.
 .TP
 .B \-\+
 Send all subsequent signals to the entire process group instead of just
-the parent process.
+the parent process. This is the default if the file
+.IB s/killpg
+is present.
+
 .TP
 .B \-L
 Send all subsequent signals to the running
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant