I am trying to make a daemon that is stopped by sending it a SIGTERM signal (as usual for daemons). The daemon gets some resources that should be freed up after startup, and I wanted to use parentheses for this.
I noticed that the bracket cleaning part does not start when the program terminates using SIGTERM. This can be reproduced using this program:
main = bracket (return "ending") (\x -> putStrLn x) (\_ -> threadDelay 10000000000000)
This simple program should get the line "ending" (for simplicity just reconfigure it) and print the resulting line at the end.
When I interrupt a program using ctrl-c, it behaves as expected and prints "termination" on exit, but when I kill it with killall -TERM test (the executable is called test), it prints "Beendet" ("Ended" ) in German), so the end of the bracket does not start.
Is this a mistake or am I doing something wrong?
I am using GHC 7.6.3 and I am working on Linux / GNU Debian jessie i386 (i686)
source share