X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/blobdiff_plain/8f45ff6cb9a269fc6f8f631908f93b4c8123419c..4aee39a18184ae8595936a03ad254c27d149a0eb:/daemonize.3 diff --git a/daemonize.3 b/daemonize.3 new file mode 100644 index 0000000..1482bed --- /dev/null +++ b/daemonize.3 @@ -0,0 +1,41 @@ +.\" -*-nroff-*- +.TH daemonize 3 "6 January 2007" "Straylight/Edgeware" "mLib utilities library" +.SH NAME +daemonize \- become a background process +.\" @detachtty +.\" @daemonize +.SH SYNOPSIS +.nf +.B "#include " + +.B "void detachtty(void);" +.B "int daemonize(void);" +.fi +.SH DESCRIPTION +The +.B daemonize +function causes the current process to become a background process. It +detaches from its controlling terminal and arranges never to acquire +another controlling terminal. If it fails for some reason (probably +because +.BR fork (2) +failed), +.B daemonize +returns \-1 and sets +.BR errno ; +on success, it returns 0. +.PP +The +.B detachtty +does half of the job of +.BR daemonize : +it detaches from its controlling terminal, and calls +.BR setsid (2) +and +.BR fork (2) +so that it can't acquire a new controlling terminal in future. Errors +are ignored. +.SH SEE ALSO +.BR mLib (3). +.SH AUTHOR +Mark Wooding,