jldupont jldupont - 1 month ago 15
Linux Question

bash pipe & sigterm

I have a bash script "script" which roughly looks like:

#!/bin/bash

cmd1 | cmd2 | cmd3


When I do a
kill script
(or more precisely when I do a 'stop script' in
supervisord
), not all cmd* are killed. How can I make sure they are terminated along with the script that spawned them?

Answer

Supervisord has a killasgroup option (false by default) which determines whether to propagate stop/terminate signals to child processes.

[program:script]
command=script
killasgroup=true

https://github.com/Supervisor/supervisor/blob/master/supervisor/process.py#L354