haskell / haskell/process

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

Open
#119 4 comments 2 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
91
Forks
91
PR merge metrics
No merged PRs in 30d

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](https://gist.github.com/gromakovsky/e55659aab6274b1ac338486e87d274c3) 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.