chiark / gitweb /
@@@ fltfmt fettling
[mLib] / sys / daemonize.3.in
1 .\" -*-nroff-*-
2 .\"
3 .\" Manual for daemonization
4 .\"
5 .\" (c) 2007, 2009, 2024 Straylight/Edgeware
6 .\"
7 .
8 .\"----- Licensing notice ---------------------------------------------------
9 .\"
10 .\" This file is part of the mLib utilities library.
11 .\"
12 .\" mLib is free software: you can redistribute it and/or modify it under
13 .\" the terms of the GNU Library General Public License as published by
14 .\" the Free Software Foundation; either version 2 of the License, or (at
15 .\" your option) any later version.
16 .\"
17 .\" mLib is distributed in the hope that it will be useful, but WITHOUT
18 .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 .\" FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
20 .\" License for more details.
21 .\"
22 .\" You should have received a copy of the GNU Library General Public
23 .\" License along with mLib.  If not, write to the Free Software
24 .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
25 .\" USA.
26 .
27 .\"--------------------------------------------------------------------------
28 .so ../defs.man \" @@@PRE@@@
29 .
30 .\"--------------------------------------------------------------------------
31 .TH daemonize 3mLib "6 January 2007" "Straylight/Edgeware" "mLib utilities library"
32 .\" @detachtty
33 .\" @daemonize
34 .
35 .\"--------------------------------------------------------------------------
36 .SH NAME
37 daemonize \- become a background process
38 .
39 .\"--------------------------------------------------------------------------
40 .SH SYNOPSIS
41 .
42 .nf
43 .B "#include <mLib/daemonize.h>"
44 .PP
45 .B "void detachtty(void);"
46 .B "int daemonize(void);"
47 .fi
48 .
49 .\"--------------------------------------------------------------------------
50 .SH DESCRIPTION
51 .
52 The
53 .B daemonize
54 function causes the current process to become a background process.  It
55 detaches from its controlling terminal and arranges never to acquire
56 another controlling terminal.  If it fails for some reason (probably
57 because
58 .BR fork (2)
59 failed),
60 .B daemonize
61 returns \-1 and sets
62 .BR errno ;
63 on success, it returns 0.
64 .PP
65 The
66 .B detachtty
67 does half of the job of
68 .BR daemonize :
69 it detaches from its controlling terminal, and calls
70 .BR setsid (2)
71 and
72 .BR fork (2)
73 so that it can't acquire a new controlling terminal in future.  Errors
74 are ignored.
75 .
76 .\"--------------------------------------------------------------------------
77 .SH SEE ALSO
78 .
79 .BR mLib (3).
80 .
81 .\"--------------------------------------------------------------------------
82 .SH AUTHOR
83 .
84 Mark Wooding, <mdw@distorted.org.uk>
85 .
86 .\"----- That's all, folks --------------------------------------------------