val daemonize : ?syslog:bool -> ?stdin:[ `Dev_null | `Close | `Keep ] -> ?stdout: [ `Dev_null | `Close | `Keep | `Log_default | `Log of Lwt_log.logger ] -> ?stderr: [ `Dev_null | `Close | `Keep | `Log_default | `Log of Lwt_log.logger ] -> ?directory:string -> ?umask:[ `Keep | `Set of int ] -> unit -> unit
Put the current running process into daemon mode. I.e. it forks and exit the parent, detach it from its controlling terminal, and redict standard intputs/outputs..
- you must be sure that there is no pending threads when calling this function, otherwise they may be canceled.
true (the default), then
Lwt_log.default is set to
Lwt_log.syslog ~facility:`Daemon (), otherwise it is kept unchanged.
stdin is one of:
`Dev_nullwhich means that
Unix.stdinis reopened as
/dev/null, this is the default behavior
Unix.stdinis simply closed
Unix.stdinis left unchanged
stderr control how the two associated file descriptors are redirected:
`Dev_nullmeans that the output is redirected to
`Closemeans that the file descriptor is closed
`Keepmeans that it is left unchanged
`Log loggermeans that the output is redirected to this logger
`Log_defaultmeans that the output is redirected to the default logger
stderr default to
Warning: do not redirect an output to a logger logging into this output. For example, this code will create an infinite loop:
let logger = Lwt_log.channel ~close_mode:`Keep ~channel:Lwt_io.stderr () in Lwt_daemon.daemonize ~syslog:false ~stderr:(`Log logger) (); prerr_endline "foo"
The current working directory is set to
directory, which defaults to
umask may be one of:
`Keepwhich means that the umask is left unchanged
`Set nwhich means that the umask is set to
It defaults to