On Fri, 2011-12-02 at 15:37 +0100, Gergely Nagy wrote:
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@wollner-net.de> Signed-off-by: Gergely Nagy <algernon@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);
After some thought I've applied this patch. It should also address Martin's issue with restarting processes. The better solution would be to keep the running program alive by putting its writer in the persist config structure so that restarts would be avoided at SIGHUP. This way we'll always restart the process, but that has happened until now anyway. Thanks Gergely. -- Bazsi