killing sshguard does not kill child process

Create issue
Issue #90 resolved
Nicolas Porcel created an issue

Hello,

When I kill sshguard with kill -TERM PID_OF_SSHGUARD, the child processes are still running. Using CTRL+C works. I am using Void Linux.

This is especially problematic when used with daemon managers that uses kill to stop processes, which could lead to several sshguard running after a service restart.

I tried to play with trap to solve the problem but I was unsuccessful. Any help would be greatly appreciated.

Nicolas

Comments (10)

  1. Kevin Zheng
    • changed status to open

    Could you run ps aux | grep sshg, paste the output, and indicate which one you were killing?

  2. Kevin Zheng

    Could you report the type and version of /bin/sh (e.g. bash, dash, zsh, etc?)

    Interesting that -TERM doesn't work but CTRL-C does. Does -INT work?

    Also, try making the 'trap' line in the sshguard driver script:

    trap "trap - TERM && kill 0" INT TERM EXIT
    
  3. Nicolas Porcel reporter

    Oh right I forgot to mention that. /bin/sh is dash.

    Actually kill -INT has no effect.

    After replacing the trap command as mentioned, kill -TERM has no effect too.

  4. Kevin Zheng

    Also reproduced on FreeBSD. Workaround is to kill any process in the pipeline instead of the driver shell itself.

  5. Kevin Zheng

    This is not strictly a bug, because passing the '-i' argument to SSHGuard writes the PID of the process you're supposed to kill. The PID file is written by sshg-blocker, which when signaled, does cause SSHGuard to terminate.

  6. Nicolas Porcel reporter

    It is always a good idea that a process cleans its children when exiting. Some service managers use cgroups to make sure all children spawned by a service are killed when the service exit. However, this solution is Linux specific and it means that the service is broken by design, which seems to be the case for sshguard. So for me it is a bug.

  7. Log in to comment