Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Closing all open file descriptors
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-09-14 (06:47)
From: Erik de Castro Lopo <mle+ocaml@m...>
Subject: Re: [Caml-list] Closing all open file descriptors
Dave Benjamin wrote:

> Did your program "daemonize" at all, then? Or did you use daemontools?

Yes, it called Unix.fork and then in the child called Unix.setsid.

Err, what's daemontools?

> I can see how it might be annoying to try to make a daemon run on stdio 
> instead, and not being able to keep the file handles open... but it 
> seems like daemons could be written to work either way if designed with 
> some care.

My program has passes around a logging function of type "string -> unit".
If it not a daemon it uses print_endline for logging and if it is a daemon 
it uses a wrapper around syslog (via the debian/ubuntu libsyslog-ocaml-dev)

> Yeah, the whole operation could be done in a C function too, and 
> probably wouldn't be much more code to write.

My daemon is only tiny, but I'm, still glad its in Ocaml.

Erik de Castro Lopo
"War is deceit."
-- Islam's prophet Mohammed (Hadith 4:268)