POSIX signals and deamons

Hi, I'm trying to create a simple daemon with hdaemonize. The deamon runs ok, but i'm having trouble with signals. Here is my test case: import Control.Monad import Control.Concurrent import System.Posix.Syslog import System.Posix.Signals import System.Posix.Daemonize main = daemonize $ do withSyslog "my-test-daemon" [PID] DAEMON $ syslog Info "daemon started" installHandler sigKILL (Catch killHandler) Nothing forever $ threadDelay 1000 killHandler = withSyslog "my-test-daemon" [PID] DAEMON $ do syslog Info "kill signal received" When I run it: $ ./test $ Everything works great: $ ps aux | grep test emanuel 12790 2.6 0.0 6552 852 ? S 20:57 0:00 ./test and: # tail /var/log/daemon.log Nov 14 20:52:06 emanuel-laptop my-test-daemon[12689]: daemon started when I do: $ kill -9 12790 process no longer exist: $ ps aux | grep test $ but/var/log/daemon.log doesn't change: # tail /var/log/daemon.log Nov 14 20:52:06 emanuel-laptop my-test-daemon[12689]: daemon started It looks like my sigKILL handler isn't called, why? Thanks, Emanuel

On Thu, Nov 14, 2013 at 3:05 PM, Emanuel Koczwara wrote: installHandler sigKILL (Catch killHandler) Nothing This should really have thrown an exception, because SIGKILL cannot be
trapped, blocked, or ignored per POSIX. Maybe you want SIGTERM?
--
brandon s allbery kf8nh sine nomine associates
allbery.b@gmail.com ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

Hi, W dniu 14.11.2013 21:10, Brandon Allbery pisze:
On Thu, Nov 14, 2013 at 3:05 PM, Emanuel Koczwara
mailto:poczta@emanuelkoczwara.pl> wrote: installHandler sigKILL (Catch killHandler) Nothing
This should really have thrown an exception, because SIGKILL cannot be trapped, blocked, or ignored per POSIX. Maybe you want SIGTERM?
You have right, sigTERM works as expected. Thank you. Emanuel
participants (2)
-
Brandon Allbery
-
Emanuel Koczwara