xref: /freebsd/usr.sbin/daemon/daemon.8 (revision b6193c2409d847dd32a04f01786eb03e6658ba79)
1bd06a3ecSMike Barcroft.\" Copyright (c) 1999 Berkeley Software Design, Inc. All rights reserved.
2bd06a3ecSMike Barcroft.\"
3bd06a3ecSMike Barcroft.\" Redistribution and use in source and binary forms, with or without
4bd06a3ecSMike Barcroft.\" modification, are permitted provided that the following conditions
5bd06a3ecSMike Barcroft.\" are met:
6bd06a3ecSMike Barcroft.\" 1. Redistributions of source code must retain the above copyright
7bd06a3ecSMike Barcroft.\"    notice, this list of conditions and the following disclaimer.
8bd06a3ecSMike Barcroft.\" 2. Redistributions in binary form must reproduce the above copyright
9bd06a3ecSMike Barcroft.\"    notice, this list of conditions and the following disclaimer in the
10bd06a3ecSMike Barcroft.\"    documentation and/or other materials provided with the distribution.
11bd06a3ecSMike Barcroft.\" 3. Berkeley Software Design Inc's name may not be used to endorse or
12bd06a3ecSMike Barcroft.\"    promote products derived from this software without specific prior
13bd06a3ecSMike Barcroft.\"    written permission.
14bd06a3ecSMike Barcroft.\"
15bd06a3ecSMike Barcroft.\" THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND
16bd06a3ecSMike Barcroft.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17bd06a3ecSMike Barcroft.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18bd06a3ecSMike Barcroft.\" ARE DISCLAIMED.  IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE
19bd06a3ecSMike Barcroft.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20bd06a3ecSMike Barcroft.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21bd06a3ecSMike Barcroft.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22bd06a3ecSMike Barcroft.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23bd06a3ecSMike Barcroft.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24bd06a3ecSMike Barcroft.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25bd06a3ecSMike Barcroft.\" SUCH DAMAGE.
26bd06a3ecSMike Barcroft.\"
27bd06a3ecSMike Barcroft.\" $FreeBSD$
28bd06a3ecSMike Barcroft.\"
292ad43027SMikolaj Golub.Dd February 19, 2012
30bd06a3ecSMike Barcroft.Dt DAEMON 8
31217758f8SRuslan Ermilov.Os
32bd06a3ecSMike Barcroft.Sh NAME
33bd06a3ecSMike Barcroft.Nm daemon
34bd06a3ecSMike Barcroft.Nd run detached from the controlling terminal
35bd06a3ecSMike Barcroft.Sh SYNOPSIS
36217758f8SRuslan Ermilov.Nm
37bd06a3ecSMike Barcroft.Op Fl cf
38846be7bdSPoul-Henning Kamp.Op Fl p Ar pidfile
39e6d4b388STom Rhodes.Op Fl u Ar user
40217758f8SRuslan Ermilov.Ar command arguments ...
41bd06a3ecSMike Barcroft.Sh DESCRIPTION
42bd06a3ecSMike BarcroftThe
43bd06a3ecSMike Barcroft.Nm
44bd06a3ecSMike Barcroftutility detaches itself from the controlling terminal and
45bd06a3ecSMike Barcroftexecutes the program specified by its arguments.
46e6d4b388STom RhodesPrivileges may be lowered to the specified user.
47bd06a3ecSMike Barcroft.Pp
48bd06a3ecSMike BarcroftThe options are as follows:
49217758f8SRuslan Ermilov.Bl -tag -width indent
50bd06a3ecSMike Barcroft.It Fl c
51217758f8SRuslan ErmilovChange the current working directory to the root
52217758f8SRuslan Ermilov.Pq Dq Pa / .
53bd06a3ecSMike Barcroft.It Fl f
54bd06a3ecSMike BarcroftRedirect standard input, standard output and standard error to
55bd06a3ecSMike Barcroft.Pa /dev/null .
56846be7bdSPoul-Henning Kamp.It Fl p Ar file
572410103cSRuslan ErmilovWrite the ID of the created process into the
58c6262cb6SPawel Jakub Dawidek.Ar file
59e6d4b388STom Rhodesusing the
60c6262cb6SPawel Jakub Dawidek.Xr pidfile 3
61c6262cb6SPawel Jakub Dawidekfunctionality.
622ad43027SMikolaj GolubThe program is executed in a spawned child process while the
632ad43027SMikolaj Golub.Nm
642ad43027SMikolaj Golubwaits until it terminates to keep the
652ad43027SMikolaj Golub.Ar file
662ad43027SMikolaj Golublocked and removes it after the process exits.
672ad43027SMikolaj GolubThe
682ad43027SMikolaj Golub.Ar file
692ad43027SMikolaj Golubowner is the user who runs the
702ad43027SMikolaj Golub.Nm
712ad43027SMikolaj Golubregardless of whether the
72704523b0SGuy Helmer.Fl u
732ad43027SMikolaj Goluboption is used or not.
74*b6193c24SMikolaj Golub.It Fl r
75*b6193c24SMikolaj GolubSupervise and restart the program if it has been terminated.
76*b6193c24SMikolaj Golub.It Fl u Ar user
77*b6193c24SMikolaj GolubLogin name of the user to execute the program under.
78*b6193c24SMikolaj GolubRequires adequate superuser privileges.
79*b6193c24SMikolaj Golub.El
80*b6193c24SMikolaj Golub.Pp
81*b6193c24SMikolaj GolubIf the
82*b6193c24SMikolaj Golub.Fl p
83*b6193c24SMikolaj Golubor
84*b6193c24SMikolaj Golub.Fl r
85*b6193c24SMikolaj Goluboption is specified the program is executed in a spawned child process.
86*b6193c24SMikolaj GolubThe
87*b6193c24SMikolaj Golub.Nm
88*b6193c24SMikolaj Golubwaits until it terminates to keep the pid file locked and removes it
89*b6193c24SMikolaj Golubafter the process exits or restarts the program.
90*b6193c24SMikolaj GolubIn this case if the monitoring
91195fc497SMikolaj Golub.Nm
92195fc497SMikolaj Golubreceives software termination signal (SIGTERM) it forwards it to the
93195fc497SMikolaj Golubspawned process.
94195fc497SMikolaj GolubNormally it will cause the child to exit followed by the termination
95195fc497SMikolaj Golubof the supervising process after removing the pidfile.
96a866e170SRuslan Ermilov.Sh EXIT STATUS
97bd06a3ecSMike BarcroftThe
98bd06a3ecSMike Barcroft.Nm
99bd06a3ecSMike Barcroftutility exits 1 if an error is returned by the
100bd06a3ecSMike Barcroft.Xr daemon 3
1012410103cSRuslan Ermilovlibrary routine, 2 if the
1022410103cSRuslan Ermilov.Ar pidfile
103c6262cb6SPawel Jakub Dawidekis requested, but cannot be opened, 3 if process is already running (pidfile
104c6262cb6SPawel Jakub Dawidekexists and is locked),
105846be7bdSPoul-Henning Kampotherwise 0.
106a866e170SRuslan Ermilov.Sh DIAGNOSTICS
107bd06a3ecSMike BarcroftIf the command cannot be executed, an error message is displayed on
108bd06a3ecSMike Barcroftstandard error unless the
109bd06a3ecSMike Barcroft.Fl f
110bd06a3ecSMike Barcroftflag is specified.
111bd06a3ecSMike Barcroft.Sh SEE ALSO
11212d7249eSTom Rhodes.Xr setregid 2 ,
11312d7249eSTom Rhodes.Xr setreuid 2 ,
114bd06a3ecSMike Barcroft.Xr daemon 3 ,
115bd06a3ecSMike Barcroft.Xr exec 3 ,
116c6262cb6SPawel Jakub Dawidek.Xr pidfile 3 ,
117bd06a3ecSMike Barcroft.Xr termios 4 ,
118bd06a3ecSMike Barcroft.Xr tty 4
119bd06a3ecSMike Barcroft.Sh HISTORY
120bd06a3ecSMike BarcroftThe
121bd06a3ecSMike Barcroft.Nm
122bd06a3ecSMike Barcroftutility first appeared in
123a7d4e017STom Rhodes.Fx 4.7 .
124