summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/pies.c1
-rw-r--r--src/pies.h27
-rw-r--r--src/progman.c22
3 files changed, 31 insertions, 19 deletions
diff --git a/src/pies.c b/src/pies.c
index 29f3ed0..bac8c41 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -871,6 +871,7 @@ str_to_cf (const char *string, int *flags)
{ "internal", CF_INTERNAL },
{ "sockenv", CF_SOCKENV },
{ "resolve", CF_RESOLVE },
+ { "siggroup", CF_SIGGROUP },
{ NULL }
};
diff --git a/src/pies.h b/src/pies.h
index 25db08a..d78d6d1 100644
--- a/src/pies.h
+++ b/src/pies.h
@@ -140,19 +140,20 @@ enum pies_comp_mode
pies_comp_pass_fd
};
-#define CF_DISABLED 0x01 /* The componenet is disabled */
-#define CF_PRECIOUS 0x02 /* The component is precious (should not
- be disabled) */
-#define CF_WAIT 0x04 /* Wait for the component instance to
- terminate. */
-#define CF_TCPMUX 0x08 /* A plain TCPMUX service */
-#define CF_TCPMUXPLUS 0x10 /* A TCPMUX-plus service, i.e. pies
- must emit a '+' response before starting
- it */
-#define CF_INTERNAL 0x20 /* An internal inetd service */
-#define CF_SOCKENV 0x40 /* Component wants socket information in
- the environment */
-#define CF_RESOLVE 0x80 /* Resolve IP addresses */
+#define CF_DISABLED 0x001 /* The componenet is disabled */
+#define CF_PRECIOUS 0x002 /* The component is precious (should not
+ be disabled) */
+#define CF_WAIT 0x004 /* Wait for the component instance to
+ terminate. */
+#define CF_TCPMUX 0x008 /* A plain TCPMUX service */
+#define CF_TCPMUXPLUS 0x010 /* A TCPMUX-plus service, i.e. pies
+ must emit a '+' response before starting
+ it */
+#define CF_INTERNAL 0x020 /* An internal inetd service */
+#define CF_SOCKENV 0x040 /* Component wants socket information in
+ the environment */
+#define CF_RESOLVE 0x080 /* Resolve IP addresses */
+#define CF_SIGGROUP 0x100 /* Send signals to the process group */
#define ISCF_TCPMUX(f) ((f) & (CF_TCPMUX | CF_TCPMUXPLUS))
diff --git a/src/progman.c b/src/progman.c
index 5e8d331..854c81a 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -1147,6 +1147,7 @@ prog_start (struct prog *prog)
/* The child branch. */
case 0:
signal_setup (SIG_DFL);
+ setsid ();
prog_start_prologue (prog);
switch (prog->v.p.comp->mode)
{
@@ -1671,6 +1672,8 @@ check_stopping (struct prog *prog, time_t now)
logmsg (LOG_EMERG,
_("INTERNAL ERROR: attempting to kill unexisting process %s"),
prog->tag);
+ else if (prog->v.p.comp->flags & CF_SIGGROUP)
+ kill (-prog->pid, SIGKILL);
else
kill (prog->pid, SIGKILL);
}
@@ -1826,7 +1829,10 @@ prog_stop (struct prog *prog, int sig)
}
}
debug (1, ("stopping %s (%lu)", prog->tag, (unsigned long) prog->pid));
- kill (prog->pid, sig);
+ if (prog->v.p.comp->flags & CF_SIGGROUP)
+ kill (-prog->pid, sig);
+ else
+ kill (prog->pid, sig);
}
static void
@@ -2040,7 +2046,7 @@ send_msg (char *rcpts, const char *msg_text)
/* Child process */
/* ============= */
signal_setup (SIG_DFL);
-
+ setsid ();
if (pipe (p))
{
logmsg (LOG_ERR, _("cannot send mail: pipe failed: %s"),
@@ -2182,6 +2188,7 @@ run_command (struct action *act, struct prog *prog, unsigned retcode,
{
debug (1, (_("executing %s"), act->command));
/* Child */
+ setsid ();
setenv ("PIES_VERSION", PACKAGE_VERSION, 1);
setenv ("PIES_COMPONENT", prog->tag, 1);
setenv ("PIES_PID", umaxtostr (child_pid, buf), 1);
@@ -2293,10 +2300,13 @@ progman_cleanup (int expect_term)
struct prog *listener = prog->v.p.listener;
listener->v.p.num_instances--;
- prog->v.p.cclass->count--;
- if (debug_level > 1)
- conn_class_report (prog->v.p.cclass);
-
+ if (prog->v.p.cclass)
+ {
+ prog->v.p.cclass->count--;
+ if (debug_level > 1)
+ conn_class_report (prog->v.p.cclass);
+ }
+
prog_stop_redirectors (prog);
destroy_prog (&prog);
react (listener, status, pid);

Return to:

Send suggestions and report system problems to the System administrator.