diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-01-02 13:30:48 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-01-02 13:30:48 +0200 |
commit | 1dbc4412111b6f7b4d61c1f1c2ba2a8d9a1c0367 (patch) | |
tree | f0a9b6c69558a7671ebdd96330dbf28460e6ff0a | |
parent | a37a83f6143e672a71ee4436fa24aaa2f9c81877 (diff) | |
download | pies-1dbc4412111b6f7b4d61c1f1c2ba2a8d9a1c0367.tar.gz pies-1dbc4412111b6f7b4d61c1f1c2ba2a8d9a1c0367.tar.bz2 |
New keyword "siggroup" + bugfix.
* src/pies.c (str_to_cf): New keyword "siggroup".
* src/pies.h (CF_SIGGROUP): New constant.
* src/progman.c (prog_start): Call setsid in child.
(check_stopping): If CF_SIGGROUP, send signal to
the process group.
(prog_stop): If CF_SIGGROUP, send signal to
the process group.
(send_msg,run_command): Call setsid in child.
(progman_cleanup): Bugfix: check if prog->v.p.cclass
is not NULL (it can be, for UDP services).
-rw-r--r-- | src/pies.c | 1 | ||||
-rw-r--r-- | src/pies.h | 27 | ||||
-rw-r--r-- | src/progman.c | 22 |
3 files changed, 31 insertions, 19 deletions
@@ -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 } }; @@ -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); |