[Haskell-cafe] how to implement daemon start and stop directives?

Belka lambda-belka at yandex.ru
Sat Jan 24 20:57:15 EST 2009

>If you want a normal daemon, you want to look at System.Posix.Process  
>to create a proper daemon (forkProcess, createSession; don't forget to  
>close stdOutput (and, errr, Haskell library types:  stdin and stderr  
>are where?  not System.Posix.IO with stdOutput) and reopen them on / 
>dev/null, at least if they're ttys as determined by  
>System.Posix.Terminal.queryTerminal).  You also want to write out a  
>pidfile (/var/run/programname.pid) for use by startproc / killproc,  
>and you want to install a handler for sigTERM  
>(System.Posix.Signals.installHandler) which sets the exit flag (TVar,  
>MVar, IORef, Chan, take your pick).  Ideally you also catch sigHUP and  
>reload your state.

Thanks for the guide, Brandon !!

By the way, I found a piece of code with function (daemonize :: IO () -> IO
()) (http://sneakymustard.com/2008/12/11/haskell-daemons), which is close to
the subject. 

I guess now I'm ready to implement my own daemon! 
Thanks for your help, everyboby!! =)
View this message in context: http://www.nabble.com/how-to-implement-daemon-start-and-stop-directives--tp21598690p21647723.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

More information about the Haskell-Cafe mailing list