Description
The only function to stop a process I found is terminateProcess
.
According to the documentation, on Unix systems it will send the SIGTERM signal.
I did some research and concluded that apparently when a Haskell process receives SIGTERM signal, it will not throw an exception to the main thread, but will stop everything rudely, so that, for example, second action passed to bracket
will not be executed. That differs from SIGINT handling which causes UserInterrupt
to be thrown. I used this code to test it.
But I want to kill a process gracefully, to allow bracket
to do all cleanup actions.
So I am wondering: shouldn't process
have a function which will do it?
Alternatively I can use System.Posix.Signals
from unix
to send SIGINT directly (and do something else on Windows). Or I can set a special handler for SIGTERM in my Haskell program which will behave akin to SIGINT.
I would appreciate any recommendations.