.\" -*-nroff-*- .\" .\" Manual for daemonization .\" .\" (c) 2007, 2009, 2024 Straylight/Edgeware .\" . .\"----- Licensing notice --------------------------------------------------- .\" .\" This file is part of the mLib utilities library. .\" .\" mLib is free software: you can redistribute it and/or modify it under .\" the terms of the GNU Library General Public License as published by .\" the Free Software Foundation; either version 2 of the License, or (at .\" your option) any later version. .\" .\" mLib is distributed in the hope that it will be useful, but WITHOUT .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public .\" License for more details. .\" .\" You should have received a copy of the GNU Library General Public .\" License along with mLib. If not, write to the Free Software .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, .\" USA. . .\"-------------------------------------------------------------------------- .so ../defs.man \" @@@PRE@@@ . .\"-------------------------------------------------------------------------- .TH daemonize 3mLib "6 January 2007" "Straylight/Edgeware" "mLib utilities library" .\" @detachtty .\" @daemonize . .\"-------------------------------------------------------------------------- .SH NAME daemonize \- become a background process . .\"-------------------------------------------------------------------------- .SH SYNOPSIS . .nf .B "#include " .PP .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, . .\"----- That's all, folks --------------------------------------------------