Skip to content

What is the recommended way to gracefully stop a Haskell process? #119

Open
@gromakovsky

Description

@gromakovsky

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions