Daniel Stephens
Daniel Stephens

Reputation: 3209

Catch SIGSTOP with SIGKILL before gracefully

Unfortunately SIGSTOP cannot be catched. Is it common or good practice to send a SIGTERM to my process before, so I can gracefully shutdown my script? There is not enough time between the two, would I require a sleep of 1 second?

kill SIGSTOP pid
... kill child processes with stop and kill
kill SIGKILL pid

P.S. What is the difference between SIGSTOP and SIGKILL?

Upvotes: 2

Views: 2273

Answers (1)

ramazan polat
ramazan polat

Reputation: 7880

SIGSTOP is a misnomer for what it does. It pauses the execution of the process and cannot be caught. SIGSTOP is usually used with SIGCONT, which reverts what SIGSTOP does and makes your process continue to run again.

SIGKILL also cannot be caught since the reason this signal exist is that your process may hang because of your code. SIGKILL kills the process and hands over the memory allocated by the process to OS.

If you want to close some connections, release a memory area or do some clean up, you can use SIGTERM which can be caught by your process.

Upvotes: 3

Related Questions