xref: /freebsd/usr.sbin/daemon/daemon.8 (revision 195fc497a26717b89f6f24b0dd0449d0f2be2acc)
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*195fc497SMikolaj GolubIf the monitoring
75*195fc497SMikolaj Golub.Nm
76*195fc497SMikolaj Golubreceives software termination signal (SIGTERM) it forwards it to the
77*195fc497SMikolaj Golubspawned process.
78*195fc497SMikolaj GolubNormally it will cause the child to exit followed by the termination
79*195fc497SMikolaj Golubof the supervising process after removing the pidfile.
80e6d4b388STom Rhodes.It Fl u Ar user
8127ad5065SIvan VorasLogin name of the user to execute the program under.
8227ad5065SIvan VorasRequires adequate superuser privileges.
83bd06a3ecSMike Barcroft.El
84a866e170SRuslan Ermilov.Sh EXIT STATUS
85bd06a3ecSMike BarcroftThe
86bd06a3ecSMike Barcroft.Nm
87bd06a3ecSMike Barcroftutility exits 1 if an error is returned by the
88bd06a3ecSMike Barcroft.Xr daemon 3
892410103cSRuslan Ermilovlibrary routine, 2 if the
902410103cSRuslan Ermilov.Ar pidfile
91c6262cb6SPawel Jakub Dawidekis requested, but cannot be opened, 3 if process is already running (pidfile
92c6262cb6SPawel Jakub Dawidekexists and is locked),
93846be7bdSPoul-Henning Kampotherwise 0.
94a866e170SRuslan Ermilov.Sh DIAGNOSTICS
95bd06a3ecSMike BarcroftIf the command cannot be executed, an error message is displayed on
96bd06a3ecSMike Barcroftstandard error unless the
97bd06a3ecSMike Barcroft.Fl f
98bd06a3ecSMike Barcroftflag is specified.
99bd06a3ecSMike Barcroft.Sh SEE ALSO
10012d7249eSTom Rhodes.Xr setregid 2 ,
10112d7249eSTom Rhodes.Xr setreuid 2 ,
102bd06a3ecSMike Barcroft.Xr daemon 3 ,
103bd06a3ecSMike Barcroft.Xr exec 3 ,
104c6262cb6SPawel Jakub Dawidek.Xr pidfile 3 ,
105bd06a3ecSMike Barcroft.Xr termios 4 ,
106bd06a3ecSMike Barcroft.Xr tty 4
107bd06a3ecSMike Barcroft.Sh HISTORY
108bd06a3ecSMike BarcroftThe
109bd06a3ecSMike Barcroft.Nm
110bd06a3ecSMike Barcroftutility first appeared in
111a7d4e017STom Rhodes.Fx 4.7 .
112