krallin / tini

A tiny but valid `init` for containers
MIT License
9.82k stars 507 forks source link

Forwarding signals to all children in session #167

Closed richard-browne closed 3 years ago

richard-browne commented 3 years ago

Suppose I have a docker container thus:

ENTRYPOINT ["/sbin/tini", "--", "entrypoint.sh"]

#!/bin/sh
crond -b
exec /usr/sbin/nginx -g daemon off

Will tini forward SIGTERM to both nginx and crond? Ie. With 'docker stop' will both my processes receive SIGTERM?

krallin commented 3 years ago

No — TIni will by default only signal its immediate child, which here will be nginx (using exec in your script replaces the /bin/sh process with TIni). You can add -g to have Tini wait for all children, but note that Tini will still only wait for its first child (i.e shel to exit). If you need something fancier, you'll want to use something a bit more complex than Tini — Tini is for reaping zombies but it's not a process manager.