[syslog-ng] [PATCH] afprog: Terminate the child process on deinit.

Gergely Nagy algernon at balabit.hu
Fri Dec 2 15:37:34 CET 2011


When reloading the configuration, terminate the child process of a
program destination, for the following reasons: it will be restarted
anyway by afprog_dd_reopen(), so there's no harm done. But if dash is
used as /bin/sh, simply closing the stdin of the process will not make
it stop.

That, in turn, results in us starting the same program over and over
again on each SIGHUP. So instead of doing this, send a SIGTERM to the
child on deinit, too.

Reported-by: Thomas Wollner <tw at wollner-net.de>
Signed-off-by: Gergely Nagy <algernon at balabit.hu>
---
 modules/afprog/afprog.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/modules/afprog/afprog.c b/modules/afprog/afprog.c
index 6ce74b0..264e85b 100644
--- a/modules/afprog/afprog.c
+++ b/modules/afprog/afprog.c
@@ -328,6 +328,16 @@ afprogram_dd_deinit(LogPipe *s)
 {
   AFProgramDestDriver *self = (AFProgramDestDriver *) s;
 
+  if (self->pid != -1)
+    {
+      msg_verbose("Sending destination program a TERM signal",
+                  evt_tag_str("cmdline", self->cmdline->str),
+                  evt_tag_int("child_pid", self->pid),
+                  NULL);
+      kill(self->pid, SIGTERM);
+      self->pid = -1;
+    }
+
   if (self->writer)
     log_pipe_deinit(self->writer);
 
-- 
1.7.7.3




More information about the syslog-ng mailing list