1 .\" Copyright (c) 1999 Berkeley Software Design, Inc. All rights reserved.
3 .\" Redistribution and use in source and binary forms, with or without
4 .\" modification, are permitted provided that the following conditions
6 .\" 1. Redistributions of source code must retain the above copyright
7 .\" notice, this list of conditions and the following disclaimer.
8 .\" 2. Redistributions in binary form must reproduce the above copyright
9 .\" notice, this list of conditions and the following disclaimer in the
10 .\" documentation and/or other materials provided with the distribution.
11 .\" 3. Berkeley Software Design Inc's name may not be used to endorse or
12 .\" promote products derived from this software without specific prior
13 .\" written permission.
15 .\" THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .Nd run detached from the controlling terminal
38 .Op Fl p Ar child_pidfile
39 .Op Fl P Ar supervisor_pidfile
42 .Op Fl m Ar output_mask
43 .Op Fl o Ar output_file
44 .Op Fl s Ar syslog_priority
45 .Op Fl T Ar syslog_tag
46 .Op Fl l Ar syslog_facility
47 .Op Fl R Ar restart_delay_seconds
48 .Ar command arguments ...
52 utility detaches itself from the controlling terminal and
53 executes the program specified by its arguments.
54 Privileges may be lowered to the specified user.
55 The output of the daemonized process may be redirected to syslog and to a
58 The options are as follows:
59 .Bl -tag -width indent
61 Change the current working directory to the root
64 Redirect standard input, standard output and standard error to
68 This is implicitly applied if other syslog parameters are provided.
69 The default values are daemon, notice, and daemon for facility, priority, and
71 .It Fl o Ar output_file
72 Append output from the daemonized process to
74 If the file does not exist, it is created with permissions 0600.
75 .It Fl m Ar output_mask
76 Redirect output from the child process stdout (1), stderr (2), or both (3).
77 This value specifies what is sent to syslog and the log file.
79 .It Fl p Ar child_pidfile
80 Write the ID of the created process into the
85 The program is executed in a spawned child process while the
87 waits until it terminates to keep the
89 locked and removes it after the process exits.
92 owner is the user who runs the
94 regardless of whether the
96 option is used or not.
97 .It Fl P Ar supervisor_pidfile
101 .Ar supervisor_pidfile
105 The program is executed in a spawned child process while the
107 waits until it terminates to keep the
108 .Ar supervisor_pidfile
109 locked and removes it after the process exits.
111 .Ar supervisor_pidfile
112 owner is the user who runs the
114 regardless of whether the
116 option is used or not.
118 Supervise and restart the program after a one-second delay if it has
120 .It Fl R Ar restart_delay_seconds
121 Supervise and restart the program after the specified delay
122 if it has been terminated.
124 Set the title for the daemon process.
125 The default is the daemonized invocation.
127 Login name of the user to execute the program under.
128 Requires adequate superuser privileges.
129 .It Fl s Ar syslog_priority
130 These priorities are accepted: emerg, alert, crit, err, warning,
131 notice, info, and debug.
132 The default is notice.
133 .It Fl l Ar syslog_facility
134 These facilities are accepted: auth, authpriv, console, cron, daemon,
135 ftp, kern, lpr, mail, news, ntp, security, syslog, user, uucp, and
137 The default is daemon.
138 .It Fl T Ar syslog_tag
139 Set the tag which is appended to all syslog messages.
140 The default is daemon.
143 If any of the options
154 are specified, the program is executed in a spawned child process.
157 waits until it terminates to keep the pid file(s) locked and removes them
158 after the process exits or restarts the program.
159 In this case if the monitoring
161 receives software termination signal (SIGTERM) it forwards it to the
163 Normally it will cause the child to exit, remove the pidfile(s)
166 If neither file or syslog output are selected, all output is redirected to the
168 process and written to stdout.
171 option may be used to suppress the stdout output completely.
175 option is useful combined with the
178 .Ar supervisor_pidfile
179 contains the ID of the supervisor
181 This is especially important if you use
183 in an rc script as the
185 option will give you the child's ID to signal when you attempt to
186 stop the service, causing
188 to restart the child.
192 utility exits 1 if an error is returned by the
194 library routine, 2 if
197 .Ar supervisor_pidfile
198 is requested, but cannot be opened, 3 if process is already running (pidfile
199 exists and is locked), 4 if
201 is not accepted, 5 if
203 is not accepted, 6 if
205 is not within the accepted range, 7 if
207 cannot be opened for appending, and otherwise 0.
209 If the command cannot be executed, an error message is printed to
211 The exact behavior depends on the logging parameters and the
226 utility first appeared in