[Haskell-beginners] POSIX signals and deamons
Emanuel Koczwara
poczta at emanuelkoczwara.pl
Thu Nov 14 20:05:41 UTC 2013
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
More information about the Beginners
mailing list