[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: start-stop-daemon: stop several processes



hvw59601 <hvw59601@care2.com> writes:

>This process is started at boot by 'do_chk_ip' in /etc/init.d which has:

>   stop)
>     start-stop-daemon --stop --verbose --exec $DAEMON
>     ;;

>where $DAEMON=/usr/bin/do_tail_chk which has:

>tail -s 1 -n 60 -f /var/log/syslog | /usr/bin/do_chk_ip

>but that starts 3 processes:

>28739 tty5     00:00:00 do_tail_chk
>28740 tty5     00:00:00 tail
>28741 tty5     00:00:00 do_chk_ip

>My stop) statement only kills 28739, how do I specify that also 28740 
>and 28741 ought to be killed?

Put "exec" before tail:

exec tail -s 1 -n 60 -f /var/log/syslog | /usr/bin/do_chk_ip

If you use exec, then the shell process that is do_tail_chk will be
replaced by the tail process which will get the same pid, so
start-stop-daemon will send the TERM signal to tail.

When tail exits, the reader on the pipe that tail was writing to will
get an EOF and will itself exit.

This all assumes that there is nothing after the "tail -s 1..." line in
the do_tail_chk script that will need to run after tail exits.



Reply to: