Skip to content
The Signal Belfry

/static/campanario/en/sino/sigterm/

Menu

SIG-004 · Termination

SIGTERM

The polite request: tidy up, close the doors, turn off the lights.

It is the generic termination signal — what kill sends when you don't ask for another, the first one systemd and Docker ring when shutting a service down. Terminate: a formal request, with the right to an answer.

The answer is the handler: close connections, save state, remove the PID file and leave of your own accord. Whoever ignores the request knows the protocol's next step — a SIGKILL after the deadline, typically ten seconds in Docker and ninety in systemd.

$ kill $(pidof -s meu-servico)
$ journalctl -u meu-servico -n 2
ago 07 14:10:22 torre meu-servico[8712]: fechando conexões...
ago 07 14:10:22 torre meu-servico[8712]: estado salvo; até logo.
The service heard the request and left through the front door.