.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` . ds C' 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DAEMON 1" .TH DAEMON 1 "20230824" "daemon-0.8.4" "User Commands" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" daemon \- turns other processes into daemons .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& usage: daemon [options] [\-\-] [cmd arg...] \& options: \& \& \-h, \-\-help \- Print a help message then exit \& \-V, \-\-version \- Print a version message then exit \& \-v, \-\-verbose[=level] \- Set the verbosity level \& \-d, \-\-debug[=level] \- Set the debugging level \& \& \-C, \-\-config=path \- Specify the system configuration file \& \-N, \-\-noconfig \- Bypass the system configuration file \& \-n, \-\-name=name \- Guarantee a single named instance \& \-X, \-\-command="cmd" \- Specify the client command as an option \& \-P, \-\-pidfiles=/dir \- Override standard pidfile location \& \-F, \-\-pidfile=/path \- Override standard pidfile name and location \& \& \-u, \-\-user=user[:[group]] \- Run the client as user[:group] \& \-R, \-\-chroot=path \- Run the client with path as root \& \-D, \-\-chdir=path \- Run the client in directory path \& \-m, \-\-umask=umask \- Run the client with the given umask \& \-e, \-\-env="var=val" \- Set a client environment variable \& \-i, \-\-inherit \- Inherit environment variables \& \-U, \-\-unsafe \- Allow execution of unsafe executable \& \-S, \-\-safe \- Disallow execution of unsafe executable \& \-c, \-\-core \- Allow core file generation \& \-\-nocore \- Disallow core file generation (default) \& \& \-r, \-\-respawn \- Respawn the client when it terminates \& \-a, \-\-acceptable=# \- Minimum acceptable client duration (seconds) \& \-A, \-\-attempts=# \- Respawn # times on error before delay \& \-L, \-\-delay=# \- Delay between respawn attempt bursts (seconds) \& \-M, \-\-limit=# \- Maximum number of respawn attempt bursts \& \-\-idiot \- Idiot mode (trust root with the above) \& \& \-f, \-\-foreground \- Run the client in the foreground \& \-p, \-\-pty[=noecho] \- Allocate a pseudo terminal for the client \& \& \-B, \-\-bind \- Stop when the user\*(Aqs last logind session ends \& \& \-l, \-\-errlog=spec \- Send daemon\*(Aqs error output to syslog or file \& \-b, \-\-dbglog=spec \- Send daemon\*(Aqs debug output to syslog or file \& \-o, \-\-output=spec \- Send client\*(Aqs output to syslog or file \& \-O, \-\-stdout=spec \- Send client\*(Aqs stdout to syslog or file \& \-E, \-\-stderr=spec \- Send client\*(Aqs stderr to syslog or file \& \& \-\-ignore\-eof \- After SIGCHLD ignore any client output \& \-\-read\-eof \- After SIGCHLD read any client output (default) \& \& \-\-running \- Check if a named daemon is running \& \-\-restart \- Restart a named daemon client \& \-\-stop \- Terminate a named daemon process \& \-\-signal=signame \- Send a signal to a named daemon \& \-\-list \- Print a list of named daemons .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fI\f(BIdaemon\fI\|(1)\fR turns other processes into daemons. There are many tasks that need to be performed to correctly set up a daemon process. This can be tedious. \fIdaemon\fR performs these tasks for other processes. .PP The preparatory tasks that \fIdaemon\fR performs for other processes are: .IP "\(bu" 4 First, revoke any setuid or setgid privileges that \fIdaemon\fR may have been installed with (by system administrators who laugh in the face of danger). .IP "\(bu" 4 Process command line options. .IP "\(bu" 4 Change the root directory if the \f(CW\*(C`\-\-chroot\*(C'\fR option was supplied. .IP "\(bu" 4 Change the process uid and gid if the \f(CW\*(C`\-\-user\*(C'\fR option was supplied. Only \&\fIroot\fR can use this option. Note that the uid of \fIdaemon\fR itself is changed, rather than just changing the uid of the client process. .IP "\(bu" 4 Read the system configuration file(s) (\f(CW\*(C`/etc/daemon.conf\*(C'\fR and \&\f(CW\*(C`/etc/daemon.conf.d/*\*(C'\fR by default, or specified by the \f(CW\*(C`\-\-config\*(C'\fR option), unless the \f(CW\*(C`\-\-noconfig\*(C'\fR option was supplied. Then read the user's personal configuration file(s) (\f(CW\*(C`~/.daemonrc\*(C'\fR and \f(CW\*(C`~/.daemonrc.d/*\*(C'\fR), if any. Generic options that apply to all daemons are processed first, then options that are specific to the daemon with the given name. \fBNote: The root directory and the user must be set before access to the configuration file(s) can be attempted, so neither the \f(CB\*(C`\-\-chroot\*(C'\fB nor \f(CB\*(C`\-\-user\*(C'\fB options may appear in the configuration file.\fR .Sp On \fI\s-1BSD\s0\fR systems (except \fImacOS\fR), the system configuration file(s) are \&\f(CW\*(C`/usr/local/etc/daemon.conf\*(C'\fR and \f(CW\*(C`/usr/local/etc/daemon.conf.d/*\*(C'\fR by default. .Sp On \fImacOS\fR, when installed via \fImacports\fR, the system configuration file(s) are \f(CW\*(C`/opt/local/etc/daemon.conf\*(C'\fR and \&\f(CW\*(C`/opt/local/etc/daemon.conf.d/*\*(C'\fR. .IP "\(bu" 4 Disable core file generation to prevent leaking potentially sensitive information in daemons that are run by \fIroot\fR (unless the \f(CW\*(C`\-\-core\*(C'\fR option was supplied). .IP "\(bu" 4 Become a daemon process: .RS 4 .IP "\(bu" 4 If \fIdaemon\fR was not invoked by \fI\f(BIinit\fI\|(8)\fR (i.e. parent process id 1) or \&\fI\f(BIinetd\fI\|(8)\fR (i.e. \f(CW\*(C`stdin\*(C'\fR is a socket): .RS 4 .IP "\(bu" 4 Ignore \f(CW\*(C`SIGHUP\*(C'\fR signals in case the current process session leader terminates while attached to a controlling terminal, causing us to receive a \f(CW\*(C`SIGHUP\*(C'\fR signal before we start our own process session below. .Sp This can happen when \fIdaemon\fR was invoked interactively via the shell builtin \f(CW\*(C`exec\*(C'\fR. When this initial process terminates below, the terminal emulator that invoked the shell also terminates, so \fIdaemon\fR need to protect itself from that. .IP "\(bu" 4 Background the process to lose process group leadership. .IP "\(bu" 4 Start a new process session. .IP "\(bu" 4 Background the process again to lose process session leadership. Under \&\fI\s-1SVR4\s0\fR, this prevents the process from ever gaining a controlling terminal. This is only necessary under \fI\s-1SVR4\s0\fR, but is always done for simplicity. Note that ignoring \f(CW\*(C`SIGHUP\*(C'\fR signals earlier means that when the newly created process session leader terminates, then even if it has a controlling terminal open, the newly backgrounded process won't receive the corresponding \f(CW\*(C`SIGHUP\*(C'\fR signal that is sent to all processes in the process session's foreground process group, because it inherited signal dispositions from the initial process. .RE .RS 4 .RE .IP "\(bu" 4 Change the current directory to the root directory so as not to hamper umounts. .IP "\(bu" 4 Clear the \fIumask\fR to enable explicit file creation modes. .IP "\(bu" 4 Close all open file descriptors. If \fIdaemon\fR was invoked by \fI\f(BIinetd\fI\|(8)\fR, \&\f(CW\*(C`stdin\*(C'\fR, \f(CW\*(C`stdout\*(C'\fR and \f(CW\*(C`stderr\*(C'\fR are left open, because they are open to a socket. .IP "\(bu" 4 Open \f(CW\*(C`stdin\*(C'\fR, \f(CW\*(C`stdout\*(C'\fR and \f(CW\*(C`stderr\*(C'\fR to \f(CW\*(C`/dev/null\*(C'\fR, in case something requires them to be open. Of course, this is not done if \fIdaemon\fR was invoked by \fI\f(BIinetd\fI\|(8)\fR. .IP "\(bu" 4 If the \f(CW\*(C`\-\-name\*(C'\fR option was supplied, create and lock a file containing the process id of the \fIdaemon\fR process. The presence of this locked file prevents two instances of a daemon with the same name from running at the same time. The default location of the pidfile is \f(CW\*(C`/var/run\*(C'\fR for \fIroot\fR (\f(CW\*(C`/etc\*(C'\fR on \fISolaris\fR, \f(CW\*(C`/opt/local/var/run\*(C'\fR on \fImacOS\fR when installed via \&\fImacports\fR), and \f(CW\*(C`/tmp\*(C'\fR for normal users. If the \f(CW\*(C`\-\-pidfiles\*(C'\fR option was supplied, its argument specifies the directory in which the pidfile will be placed. If the \f(CW\*(C`\-\-pidfile\*(C'\fR option was supplied, its argument specifies the name of the pidfile and the directory in which it will be placed. .RE .RS 4 .RE .IP "\(bu" 4 If the \f(CW\*(C`\-\-umask\*(C'\fR option was supplied, set the \fIumask\fR to its argument, which must be a valid three-digit octal mode. Otherwise, set the umask to \&\f(CW022\fR, to prevent clients from accidentally creating group\- or world-writable files. .IP "\(bu" 4 Set the current directory if the \f(CW\*(C`\-\-chdir\*(C'\fR option was supplied. .IP "\(bu" 4 Spawn the client command and wait for it to terminate. The client command can be specified as command line arguments, or as the argument of the \&\f(CW\*(C`\-\-command\*(C'\fR option. If both the \f(CW\*(C`\-\-command\*(C'\fR option and command line arguments are present, the client command is the result of appending the command line arguments to the argument of the \f(CW\*(C`\-\-command\*(C'\fR option. .IP "\(bu" 4 If the \f(CW\*(C`\-\-output\*(C'\fR, \f(CW\*(C`\-\-stdout\*(C'\fR and/or \f(CW\*(C`\-\-stderr\*(C'\fR options were supplied, the client's standard output and/or standard error are captured by \&\fIdaemon\fR, and are sent to the respective \fIsyslog\fR destinations. .IP "\(bu" 4 When the client terminates, \fIdaemon\fR respawns it if the \f(CW\*(C`\-\-respawn\*(C'\fR option was supplied. If the client ran for less than \f(CW300\fR seconds (or the value of the \f(CW\*(C`\-\-acceptable\*(C'\fR option), then \fIdaemon\fR sees this as a failure. It will attempt to restart the client up to five times (or the value of the \&\f(CW\*(C`\-\-attempts\*(C'\fR option), before waiting for \f(CW300\fR seconds (or the value of the \f(CW\*(C`\-\-delay\*(C'\fR option). This gives the system administrator the chance to correct whatever is preventing the client from running successfully without overloading system resources. If the \f(CW\*(C`\-\-limit\*(C'\fR option was supplied, \&\fIdaemon\fR terminates after the specified number of respawn attempt bursts. The default is zero, which means never give up, never surrender. .Sp When the client terminates, and the \f(CW\*(C`\-\-respawn\*(C'\fR option wasn't supplied, \&\fIdaemon\fR terminates as well. .IP "\(bu" 4 If \fIdaemon\fR receives a \f(CW\*(C`SIGTERM\*(C'\fR signal (e.g. from a separate invocation of \fIdaemon\fR with the \f(CW\*(C`\-\-stop\*(C'\fR option), it propagates the signal to the client and then terminates. .IP "\(bu" 4 If \fIdaemon\fR receives a \f(CW\*(C`SIGUSR1\*(C'\fR signal (from a separate invocation of \&\fIdaemon\fR with the \f(CW\*(C`\-\-restart\*(C'\fR option), it sends a \f(CW\*(C`SIGTERM\*(C'\fR signal to the client. If it was started with the \f(CW\*(C`\-\-respawn\*(C'\fR option, the client process will be restarted after it is terminated by the \f(CW\*(C`SIGTERM\*(C'\fR signal. .IP "\(bu" 4 If the \f(CW\*(C`\-\-foreground\*(C'\fR option was supplied, the client process is run as a foreground process, and is not turned into a daemon at all. If \fIdaemon\fR is connected to a terminal, then the client process will also be connected to it. If \fIdaemon\fR is not connected to a terminal, but the client needs to be connected to a terminal, use the \f(CW\*(C`\-\-pty\*(C'\fR option. .SH "OPTIONS" .IX Header "OPTIONS" .ie n .IP "\*(C`\-h\*(C', \*(C`\-\-help\*(C'" 4 .el .IP "\f(CW\*(C`\-h\*(C'\fR, \f(CW\*(C`\-\-help\*(C'\fR" 4 .IX Item "-h, --help" Display a help message and exit. .ie n .IP "\*(C`\-V\*(C', \*(C`\-\-version\*(C'" 4 .el .IP "\f(CW\*(C`\-V\*(C'\fR, \f(CW\*(C`\-\-version\*(C'\fR" 4 .IX Item "-V, --version" Display a version message and exit. .ie n .IP "\*(C`\-v\*(C'\fI[level]\fR, \*(C`\-\-verbose\*(C'\fI[=level]\fR" 4 .el .IP "\f(CW\*(C`\-v\*(C'\fR\fI[level]\fR, \f(CW\*(C`\-\-verbose\*(C'\fR\fI[=level]\fR" 4 .IX Item "-v[level], --verbose[=level]" Set the message verbosity level to \fIlevel\fR (or 1 if \fIlevel\fR is not supplied). This only effects the \f(CW\*(C`\-\-running\*(C'\fR and \f(CW\*(C`\-\-list\*(C'\fR options. .ie n .IP "\*(C`\-d\*(C'\fI[level]\fR, \*(C`\-\-debug\*(C'\fI[=level]\fR" 4 .el .IP "\f(CW\*(C`\-d\*(C'\fR\fI[level]\fR, \f(CW\*(C`\-\-debug\*(C'\fR\fI[=level]\fR" 4 .IX Item "-d[level], --debug[=level]" Set the debug message level to \fIlevel\fR (or 1 if \fIlevel\fR is not supplied). Level 1 traces high-level function calls. Level 2 traces lower-level function calls and shows configuration information. Level 3 adds environment variables. Level 9 adds every return value from \fI\f(BIselect\fI\|(2)\fR. Debug messages are sent to the destination specified by the \f(CW\*(C`\-\-dbglog\*(C'\fR option (by default, the \fI\f(BIsyslog\fI\|(3)\fR facility, \f(CW\*(C`daemon.debug\*(C'\fR). .ie n .IP "\*(C`\-C\*(C' \fIpath\fR, \*(C`\-\-config=\*(C'\fIpath\fR" 4 .el .IP "\f(CW\*(C`\-C\*(C'\fR \fIpath\fR, \f(CW\*(C`\-\-config=\*(C'\fR\fIpath\fR" 4 .IX Item "-C path, --config=path" Specify the system configuration file to use. By default, \&\f(CW\*(C`/etc/daemon.conf\*(C'\fR is the system configuration file, if it exists and is not group\- or world-writable, and does not exist in a group\- or world-writable directory. The configuration file lets you predefine options that apply to all clients, and to specifically named clients. .Sp As well as the system configuration file, additional configuration files will be read from the directory whose path matches the system configuration file with \f(CW".d"\fR appended to it (e.g. \f(CW\*(C`/etc/daemon.conf.d\*(C'\fR). Any file in that directory whose name starts with a dot character (\f(CW"."\fR) is ignored. The same checks as described above apply to these files as well. .Sp On \fI\s-1BSD\s0\fR systems (except \fImacOS\fR), the system configuration file(s) are \&\f(CW\*(C`/usr/local/etc/daemon.conf\*(C'\fR and \f(CW\*(C`/usr/local/etc/daemon.conf.d/*\*(C'\fR by default. .Sp On \fImacOS\fR, when installed via \fImacports\fR, the system configuration file(s) are \f(CW\*(C`/opt/local/etc/daemon.conf\*(C'\fR and \&\f(CW\*(C`/opt/local/etc/daemon.conf.d/*\*(C'\fR. .ie n .IP "\*(C`\-N\*(C', \*(C`\-\-noconfig\*(C'" 4 .el .IP "\f(CW\*(C`\-N\*(C'\fR, \f(CW\*(C`\-\-noconfig\*(C'\fR" 4 .IX Item "-N, --noconfig" Bypass the system configuration files, \f(CW\*(C`/etc/daemon.conf\*(C'\fR and \&\f(CW\*(C`/etc/daemon.conf.d/*\*(C'\fR. Only the user's \f(CW\*(C`~/.daemonrc\*(C'\fR and \&\f(CW\*(C`~/.daemonrc.d/*\*(C'\fR configuration files will be read (if they exist). .ie n .IP "\*(C`\-n\*(C' \fIname\fR, \*(C`\-\-name=\*(C'\fIname\fR" 4 .el .IP "\f(CW\*(C`\-n\*(C'\fR \fIname\fR, \f(CW\*(C`\-\-name=\*(C'\fR\fIname\fR" 4 .IX Item "-n name, --name=name" Create and lock a pidfile (\fIname\fR\f(CW\*(C`.pid\*(C'\fR), ensuring that only one daemon with the given \fIname\fR is active at the same time. The standard location of the pidfile is \f(CW\*(C`/var/run\*(C'\fR for root (\f(CW\*(C`/etc\*(C'\fR on \fISolaris\fR, \&\f(CW\*(C`/opt/local/var/run\*(C'\fR on \fImacOS\fR when installed via \fImacports\fR), and \&\f(CW\*(C`/tmp\*(C'\fR for normal users. This location can be overridden with the \&\fI\-\-pidfiles\fR option. .Sp The name may only consist of the following characters: .Sp .Vb 1 \& \-._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 .Ve .Sp While a named daemon's client process is running, there will also be a separate pidfile to record the process id of the client process. Its filename will be the same as the \fIdaemon\fR pidfile's, except that the filename extension will be \f(CW\*(C`.clientpid\*(C'\fR rather than \f(CW\*(C`.pid\*(C'\fR. The only reason that there should be a \f(CW\*(C`.pid\*(C'\fR file, with no \f(CW\*(C`.clientpid\*(C'\fR file, is during the delay between respawn attempts bursts. .ie n .IP "\*(C`\-X\*(C' \fI""cmd""\fR, \*(C`\-\-command=\*(C'\fI""cmd""\fR" 4 .el .IP "\f(CW\*(C`\-X\*(C'\fR \fI``cmd''\fR, \f(CW\*(C`\-\-command=\*(C'\fR\fI``cmd''\fR" 4 .IX Item "-X cmd, --command=cmd" Specify the client command as an option. If a command is specified along with its name in the configuration file, then a daemon can be invoked merely by mentioning its name: .Sp .Vb 1 \& daemon \-\-name ftumch .Ve .Sp \&\fBNote:\fR If the client command is specified with the \f(CW\*(C`\-\-command\*(C'\fR option, either in the configuration file, or on the command line, then any additional command line arguments on the \fIdaemon\fR command line are appended to the client command that is specified with the \f(CW\*(C`\-\-command\*(C'\fR option. .ie n .IP "\*(C`\-P\*(C' \fI/dir\fR, \*(C`\-\-pidfiles=\*(C'\fI/dir\fR" 4 .el .IP "\f(CW\*(C`\-P\*(C'\fR \fI/dir\fR, \f(CW\*(C`\-\-pidfiles=\*(C'\fR\fI/dir\fR" 4 .IX Item "-P /dir, --pidfiles=/dir" Override the standard pidfile location. The standard pidfile location is \&\f(CW\*(C`/var/run\*(C'\fR for root (\f(CW\*(C`/etc\*(C'\fR on \fISolaris\fR, \f(CW\*(C`/opt/local/var/run\*(C'\fR on \&\fImacOS\fR when installed via \fImacports\fR), and \f(CW\*(C`/tmp\*(C'\fR for normal users. .Sp This option only affects the \f(CW\*(C`\-\-name\*(C'\fR and \f(CW\*(C`\-\-list\*(C'\fR options. Use this option if these standard locations are unacceptable, but make sure that you don't forget where you put your pidfiles. This option is best used in configuration files, or in shell scripts, rather than on an interactive command line. .Sp The pidfile location will be created automatically only if it is within the user's home directory. .ie n .IP "\*(C`\-F\*(C' \fI/path\fR, \*(C`\-\-pidfile=\*(C'\fI/path\fR" 4 .el .IP "\f(CW\*(C`\-F\*(C'\fR \fI/path\fR, \f(CW\*(C`\-\-pidfile=\*(C'\fR\fI/path\fR" 4 .IX Item "-F /path, --pidfile=/path" Override the standard pidfile name and location. The standard pidfile location is described immediately above. The standard pidfile name is the argument of the \f(CW\*(C`\-\-name\*(C'\fR option followed by \f(CW\*(C`.pid\*(C'\fR. Use this option if the standard pidfile name and location are unacceptable, but make sure that you don't forget where you put your pidfile. This option is best used in configuration files, or in shell scripts, rather than on an interactive command line. .Sp The pidfile location will be created automatically only if it is within the user's home directory. .ie n .IP "\*(C`\-u\*(C' \fIuser[:[group]]\fR, \*(C`\-\-user=\*(C'\fIuser[:[group]]\fR" 4 .el .IP "\f(CW\*(C`\-u\*(C'\fR \fIuser[:[group]]\fR, \f(CW\*(C`\-\-user=\*(C'\fR\fIuser[:[group]]\fR" 4 .IX Item "-u user[:[group]], --user=user[:[group]]" Run the client as a different user (and group). This only works for \fIroot\fR. If the argument includes a \fI:group\fR specifier, \fIdaemon\fR will assume the specified group and no other. Otherwise, \fIdaemon\fR will assume all groups that the specified user is in. For backwards compatibility, \f(CW"."\fR may be used instead of \f(CW":"\fR to separate the user and group but since \f(CW"."\fR can appear in user and group names, ambiguities can arise such as using \&\f(CW\*(C`\-\-user=\*(C'\fR\fIu.g\fR when users \fIu\fR and \fIu.g\fR and group \fIg\fR all exist. With such an ambiguity, \fIdaemon\fR will assume the user \fIu\fR and group \fIg\fR. Use \&\f(CW\*(C`\-\-user=\*(C'\fR\fIu.g:\fR instead for the other interpretation. .ie n .IP "\*(C`\-R\*(C' \fIpath\fR, \*(C`\-\-chroot=\*(C'\fIpath\fR" 4 .el .IP "\f(CW\*(C`\-R\*(C'\fR \fIpath\fR, \f(CW\*(C`\-\-chroot=\*(C'\fR\fIpath\fR" 4 .IX Item "-R path, --chroot=path" Change the root directory to \fIpath\fR before running the client. On some systems, only \fIroot\fR can do this. Note that the path to the client program and to the configuration file (if any) must be relative to the new root path. .ie n .IP "\*(C`\-D\*(C' \fIpath\fR, \*(C`\-\-chdir=\*(C'\fIpath\fR" 4 .el .IP "\f(CW\*(C`\-D\*(C'\fR \fIpath\fR, \f(CW\*(C`\-\-chdir=\*(C'\fR\fIpath\fR" 4 .IX Item "-D path, --chdir=path" Change the current directory to \fIpath\fR before running the client. The default current directory is the root directory (possibly after \fIchroot\fR). .ie n .IP "\*(C`\-m\*(C' \fIumask\fR, \*(C`\-\-umask=\*(C'\fIumask\fR" 4 .el .IP "\f(CW\*(C`\-m\*(C'\fR \fIumask\fR, \f(CW\*(C`\-\-umask=\*(C'\fR\fIumask\fR" 4 .IX Item "-m umask, --umask=umask" Change the umask to \fIumask\fR before running the client. \fIumask\fR must be a valid octal mode. The default umask is \f(CW022\fR. .ie n .IP "\*(C`\-e\*(C' \fI""var=val""\fR, \*(C`\-\-env=\*(C'\fI""var=val""\fR" 4 .el .IP "\f(CW\*(C`\-e\*(C'\fR \fI``var=val''\fR, \f(CW\*(C`\-\-env=\*(C'\fR\fI``var=val''\fR" 4 .IX Item "-e var=val, --env=var=val" Set an environment variable for the client process. This option can be used any number of times. If it is used, only the supplied environment variables are passed to the client process. Otherwise, the client process inherits the current set of environment variables. .ie n .IP "\*(C`\-i\*(C', \*(C`\-\-inherit\*(C'" 4 .el .IP "\f(CW\*(C`\-i\*(C'\fR, \f(CW\*(C`\-\-inherit\*(C'\fR" 4 .IX Item "-i, --inherit" Explicitly inherit environment variables. This is only needed when the \&\f(CW\*(C`\-\-env\*(C'\fR option is used. When this option is used, the \f(CW\*(C`\-\-env\*(C'\fR option adds to the inherited environment, rather than replacing it. .ie n .IP "\*(C`\-U\*(C', \*(C`\-\-unsafe\*(C'" 4 .el .IP "\f(CW\*(C`\-U\*(C'\fR, \f(CW\*(C`\-\-unsafe\*(C'\fR" 4 .IX Item "-U, --unsafe" Allow reading an unsafe configuration file, and allow the execution of an unsafe executable. A configuration file or executable is considered to be unsafe if it is group\- or world-writable or is in a directory that is group\- or world-writable (following symbolic links). If an executable is a script that is interpreted by another executable, then it is considered to be unsafe if the interpreter is unsafe. If the interpreter is \f(CW\*(C`/usr/bin/env\*(C'\fR (with an argument that is a command name to be searched for in \f(CW$PATH\fR), then that command must be safe. By default, \fI\f(BIdaemon\fI\|(1)\fR will refuse to read an unsafe configuration file or to execute an unsafe executable when run by \&\fIroot\fR. This option overrides that behaviour and hence should never be used. .ie n .IP "\*(C`\-S\*(C', \*(C`\-\-safe\*(C'" 4 .el .IP "\f(CW\*(C`\-S\*(C'\fR, \f(CW\*(C`\-\-safe\*(C'\fR" 4 .IX Item "-S, --safe" Disallow reading an unsafe configuration file, and disallow the execution of an unsafe executable. By default, \fI\f(BIdaemon\fI\|(1)\fR will allow reading an unsafe configuration file, and allow the execution of an unsafe executable, when run by normal users. This option overrides that behaviour. .ie n .IP "\*(C`\-c\*(C', \*(C`\-\-core\*(C'" 4 .el .IP "\f(CW\*(C`\-c\*(C'\fR, \f(CW\*(C`\-\-core\*(C'\fR" 4 .IX Item "-c, --core" Allow the client to create a core file. This should only be used for debugging, as it could lead to security-related information disclosures by daemons run by \fIroot\fR. .ie n .IP "\*(C`\-\-nocore\*(C'" 4 .el .IP "\f(CW\*(C`\-\-nocore\*(C'\fR" 4 .IX Item "--nocore" By default, clients are prevented from creating a core file. If the \&\f(CW\*(C`\-\-core\*(C'\fR option has been used in a configuration file to apply to all named daemons, then this option can be used to restore the default behaviour for specific named daemons. .ie n .IP "\*(C`\-r\*(C', \*(C`\-\-respawn\*(C'" 4 .el .IP "\f(CW\*(C`\-r\*(C'\fR, \f(CW\*(C`\-\-respawn\*(C'\fR" 4 .IX Item "-r, --respawn" Respawn the client when it terminates. Without this option, the termination of a client process causes \fIdaemon\fR itself to terminate as well. .ie n .IP "\*(C`\-a\*(C' \fI#\fR, \*(C`\-\-acceptable=\*(C'\fI#\fR" 4 .el .IP "\f(CW\*(C`\-a\*(C'\fR \fI#\fR, \f(CW\*(C`\-\-acceptable=\*(C'\fR\fI#\fR" 4 .IX Item "-a #, --acceptable=#" Specify the minimum acceptable duration of a client process, in seconds. This option can only be used with the \f(CW\*(C`\-\-respawn\*(C'\fR option. If a client process terminates before this threshold is reached, then it is considered to have failed. The default value is \f(CW300\fR seconds. It cannot be set to less than \f(CW10\fR seconds, except by \fIroot\fR when used in conjunction with the \&\f(CW\*(C`\-\-idiot\*(C'\fR option. .ie n .IP "\*(C`\-A\*(C' \fI#\fR, \*(C`\-\-attempts=\*(C'\fI#\fR" 4 .el .IP "\f(CW\*(C`\-A\*(C'\fR \fI#\fR, \f(CW\*(C`\-\-attempts=\*(C'\fR\fI#\fR" 4 .IX Item "-A #, --attempts=#" Specify the number of attempts to respawn before delaying. This option can only be used with the \f(CW\*(C`\-\-respawn\*(C'\fR option. The default value is \f(CW5\fR. It cannot be set to more than \f(CW100\fR attempts, except by \fIroot\fR when used in conjunction with the \f(CW\*(C`\-\-idiot\*(C'\fR option. .ie n .IP "\*(C`\-L\*(C' \fI#\fR, \*(C`\-\-delay=\*(C'\fI#\fR" 4 .el .IP "\f(CW\*(C`\-L\*(C'\fR \fI#\fR, \f(CW\*(C`\-\-delay=\*(C'\fR\fI#\fR" 4 .IX Item "-L #, --delay=#" Specify the delay in seconds between each burst of respawn attempts. This option can only be used with the \f(CW\*(C`\-\-respawn\*(C'\fR option. The default value is \&\f(CW300\fR seconds. It cannot be set to less than \f(CW10\fR seconds except by \&\fIroot\fR when used in conjunction with the \f(CW\*(C`\-\-idiot\*(C'\fR option. .ie n .IP "\*(C`\-M\*(C' \fI#\fR, \*(C`\-\-limit=\*(C'\fI#\fR" 4 .el .IP "\f(CW\*(C`\-M\*(C'\fR \fI#\fR, \f(CW\*(C`\-\-limit=\*(C'\fR\fI#\fR" 4 .IX Item "-M #, --limit=#" Specify a limit to the number of respawn attempt bursts. This option can only be used with the \f(CW\*(C`\-\-respawn\*(C'\fR option. The default value is \f(CW0\fR, which means no limit. .ie n .IP "\*(C`\-\-idiot\*(C'" 4 .el .IP "\f(CW\*(C`\-\-idiot\*(C'\fR" 4 .IX Item "--idiot" Turn on idiot mode in which \fIdaemon\fR will not enforce the minimum or maximum values normally imposed on the \f(CW\*(C`\-\-acceptable\*(C'\fR, \f(CW\*(C`\-\-attempts\*(C'\fR and \&\f(CW\*(C`\-\-delay\*(C'\fR options. The \f(CW\*(C`\-\-idiot\*(C'\fR option must appear before any of these options. Only the \fIroot\fR user may use this option, because it can turn a slight misconfiguration into a lot of wasted \s-1CPU\s0 energy and log messages, somewhat akin to a self-inflicted denial of service. .Sp Idiot mode also allows the \fIroot\fR user to expand environment variable notation (e.g. \f(CW$VAR\fR and \f(CW\*(C`${VAR}\*(C'\fR) in command line option arguments, and in configuration files. By default, internal environment variable expansion is only performed for normal users. Note that this doesn't apply to any such expansion performed earlier by the shell that invokes \fI\f(BIdaemon\fI\|(1)\fR. See the \&\f(CW\*(C`EXPANSION\*(C'\fR section below for more details. .ie n .IP "\*(C`\-f\*(C', \*(C`\-\-foreground\*(C'" 4 .el .IP "\f(CW\*(C`\-f\*(C'\fR, \f(CW\*(C`\-\-foreground\*(C'\fR" 4 .IX Item "-f, --foreground" Run the client in the foreground. The client is not turned into a daemon. .ie n .IP "\*(C`\-p\*(C'\fI[noecho]\fR, \*(C`\-\-pty\*(C'\fI[=noecho]\fR" 4 .el .IP "\f(CW\*(C`\-p\*(C'\fR\fI[noecho]\fR, \f(CW\*(C`\-\-pty\*(C'\fR\fI[=noecho]\fR" 4 .IX Item "-p[noecho], --pty[=noecho]" Connect the client to a pseudo terminal. This option can only be used with the \f(CW\*(C`\-\-foreground\*(C'\fR option. This is the default when the \f(CW\*(C`\-\-foreground\*(C'\fR option is supplied and \fIdaemon\fR's standard input is connected to a terminal. This option is only necessary when the client process must be connected to a controlling terminal, but \fIdaemon\fR itself has been run without a controlling terminal (e.g. from \fI\f(BIcron\fI\|(8)\fR or a pipeline). .Sp If the \f(CW\*(C`noecho\*(C'\fR argument is supplied with this option, the client's side of the pseudo terminal will be set to \f(CW\*(C`noecho\*(C'\fR mode. Use this only if there really is a terminal involved and input is being echoed twice. .ie n .IP "\*(C`\-B\*(C', \*(C`\-\-bind\*(C'" 4 .el .IP "\f(CW\*(C`\-B\*(C'\fR, \f(CW\*(C`\-\-bind\*(C'\fR" 4 .IX Item "-B, --bind" Automatically terminate the client process (and \fI\f(BIdaemon\fI\|(1)\fR itself) as soon as the user has no \fI\f(BIsystemd\-logind\fI\|(8)\fR (or \fI\f(BIelogind\fI\|(8)\fR) user sessions. In other words, automatically terminate when the user logs out. If the user has no sessions to start with, the client process will be terminated immediately. .Sp This option is only available on \fILinux\fR systems that have either \&\fI\f(BIsystemd\fI\|(1)\fR (e.g. \fIDebian\fR) or \fI\f(BIelogind\fI\|(8)\fR (e.g. \fISlackware\fR). On systems with \fI\f(BIsystemd\fI\|(1)\fR, you could instead use a \fIsystemd\fR user service, particularly if your user account is not allowed to have user services that \&\fIlinger\fR. .ie n .IP "\*(C`\-l\*(C' \fIspec\fR, \*(C`\-\-errlog=\*(C'\fIspec\fR" 4 .el .IP "\f(CW\*(C`\-l\*(C'\fR \fIspec\fR, \f(CW\*(C`\-\-errlog=\*(C'\fR\fIspec\fR" 4 .IX Item "-l spec, --errlog=spec" Send \fIdaemon\fR's standard output and standard error to the syslog destination or file that is specified by \fIspec\fR. If \fIspec\fR is a syslog destination of the form \f(CW"facility.priority"\fR, then output is sent to \&\fI\f(BIsyslog\fI\|(3)\fR. Otherwise, output is appended to the file whose path is given in \fIspec\fR. By default, output is sent to the syslog destination, \&\f(CW\*(C`daemon.err\*(C'\fR. See the \f(CW\*(C`MESSAGING\*(C'\fR section below for more details. .ie n .IP "\*(C`\-b\*(C' \fIspec\fR, \*(C`\-\-dbglog=\*(C'\fIspec\fR" 4 .el .IP "\f(CW\*(C`\-b\*(C'\fR \fIspec\fR, \f(CW\*(C`\-\-dbglog=\*(C'\fR\fIspec\fR" 4 .IX Item "-b spec, --dbglog=spec" Send \fIdaemon\fR's debug output to the syslog destination or file that is specified by \fIspec\fR. If \fIspec\fR is a syslog destination of the form \&\f(CW"facility.priority"\fR, then output is sent to \fI\f(BIsyslog\fI\|(3)\fR. Otherwise, output is appended to the file whose path is given in \fIspec\fR. By default, output is sent to the syslog destination \f(CW\*(C`daemon.debug\*(C'\fR. See the \&\f(CW\*(C`MESSAGING\*(C'\fR section below for more details. .ie n .IP "\*(C`\-o\*(C' \fIspec\fR, \*(C`\-\-output=\*(C'\fIspec\fR" 4 .el .IP "\f(CW\*(C`\-o\*(C'\fR \fIspec\fR, \f(CW\*(C`\-\-output=\*(C'\fR\fIspec\fR" 4 .IX Item "-o spec, --output=spec" Capture the client's standard output and standard error, and send it to the syslog destination or file that is specified by \fIspec\fR. If \fIspec\fR is a syslog destination of the form \f(CW"facility.priority"\fR, then output is sent to \fI\f(BIsyslog\fI\|(3)\fR. Otherwise, output is appended to the file whose path is given in \fIspec\fR. By default, output is discarded unless the \f(CW\*(C`\-\-foreground\*(C'\fR option is present, in which case, the client's stdout and stderr are propagated to \fIdaemon\fR's stdout and stderr, respectively. See the \&\f(CW\*(C`MESSAGING\*(C'\fR section below for more details. .ie n .IP "\*(C`\-O\*(C' \fIspec\fR, \*(C`\-\-stdout=\*(C'\fIspec\fR" 4 .el .IP "\f(CW\*(C`\-O\*(C'\fR \fIspec\fR, \f(CW\*(C`\-\-stdout=\*(C'\fR\fIspec\fR" 4 .IX Item "-O spec, --stdout=spec" Capture the client's standard output, and send it to the syslog destination or file that is specified by \fIspec\fR. If \fIspec\fR is a syslog destination of the form \f(CW"facility.priority"\fR, then output is sent to \fI\f(BIsyslog\fI\|(3)\fR. Otherwise, stdout is appended to the file whose path is given in \fIspec\fR. By default, stdout is discarded unless the \f(CW\*(C`\-\-foreground\*(C'\fR option is present, in which case, the client's stdout is propagated to \fIdaemon\fR's stdout. See the \f(CW\*(C`MESSAGING\*(C'\fR section below for more details. .ie n .IP "\*(C`\-E\*(C' \fIspec\fR, \*(C`\-\-stderr=\*(C'\fIspec\fR" 4 .el .IP "\f(CW\*(C`\-E\*(C'\fR \fIspec\fR, \f(CW\*(C`\-\-stderr=\*(C'\fR\fIspec\fR" 4 .IX Item "-E spec, --stderr=spec" Capture the client's standard error, and send it to the syslog destination or file that is specified by \fIspec\fR. If \fIspec\fR is a syslog destination of the form \f(CW"facility.priority"\fR, then stderr is sent to \fI\f(BIsyslog\fI\|(3)\fR. Otherwise, stderr is appended to the file whose path is given in \fIspec\fR. By default, stderr is discarded unless the \f(CW\*(C`\-\-foreground\*(C'\fR option is present, in which case, the client's stderr is propagated to \fIdaemon\fR's stderr. See the \f(CW\*(C`MESSAGING\*(C'\fR section below for more details. .ie n .IP "\*(C`\-\-ignore\-eof\*(C'" 4 .el .IP "\f(CW\*(C`\-\-ignore\-eof\*(C'\fR" 4 .IX Item "--ignore-eof" After receiving a \f(CW\*(C`SIGCHLD\*(C'\fR signal due to a stopped or restarted client process, don't bother reading the client's output until the end-of-file is reached before reaping the client process's termination status with \&\fI\f(BIwait\fI\|(2)\fR. Normally, there will be little or no output after the \f(CW\*(C`SIGCHLD\*(C'\fR signal, because the client process has just terminated. However, the client process might have its own child processes keeping its output open long after its own termination. When this happens, by default, the client process remains as a zombie process until its child processes terminate and close the output. Waiting for the client's child processes to terminate before considering the client stopped, and before restarting a new invocation, might be desirable. If not, this option can be used to consider the client process as being terminated as soon as the \f(CW\*(C`SIGCHLD\*(C'\fR signal has been received, and reaping its termination status with \fI\f(BIwait\fI\|(2)\fR immediately. .ie n .IP "\*(C`\-\-read\-eof\*(C'" 4 .el .IP "\f(CW\*(C`\-\-read\-eof\*(C'\fR" 4 .IX Item "--read-eof" After receiving a \f(CW\*(C`SIGCHLD\*(C'\fR signal due to a stopped or restarted client process, continue reading the client's output until the end-of-file is reached before reaping the client process's termination status with \&\fI\f(BIwait\fI\|(2)\fR. This is the default behaviour. Normally, there will be little or no output after the \f(CW\*(C`SIGCHLD\*(C'\fR signal, because the client process has just terminated. However, the client process might have its own child processes keeping its output open long after its own termination. When this happens, the client process remains as a zombie process until its child processes terminate and close the output. Waiting for the client's child processes to terminate before considering the client stopped, and before restarting a new invocation, might be desirable. If so, but the \f(CW\*(C`\-\-ignore\-eof\*(C'\fR option has been used in a configuration file to apply to all named daemons, then this option can be used to restore the default behaviour for specific named daemons. .ie n .IP "\*(C`\-\-running\*(C'" 4 .el .IP "\f(CW\*(C`\-\-running\*(C'\fR" 4 .IX Item "--running" Check whether or not a named daemon is running, then \fI\f(BIexit\fI\|(3)\fR with \&\f(CW\*(C`EXIT_SUCCESS\*(C'\fR if the named daemon is running or \f(CW\*(C`EXIT_FAILURE\*(C'\fR if it isn't. .Sp If the \f(CW\*(C`\-\-verbose\*(C'\fR option is supplied, print a message before exiting. If both the named daemon and its client process are running, the output will look like this, showing both process IDs: .Sp .Vb 1 \& daemon: name is running (pid 7455) (clientpid 7457) .Ve .Sp If the named daemon is running but its client process is not (there might be a delay between respawn attempt bursts), the output will look like this, showing only the daemon process's \s-1ID:\s0 .Sp .Vb 1 \& daemon: name is running (pid 7455) (client is not running) .Ve .Sp If the named daemon is not running at all, the output will look like this: .Sp .Vb 1 \& daemon: name is not running .Ve .Sp This option can only be used with the \f(CW\*(C`\-\-name\*(C'\fR option. Note that the \&\f(CW\*(C`\-\-chroot\*(C'\fR, \f(CW\*(C`\-\-user\*(C'\fR, \f(CW\*(C`\-\-name\*(C'\fR, \f(CW\*(C`\-\-pidfiles\*(C'\fR and \f(CW\*(C`\-\-pidfile\*(C'\fR (and possibly \f(CW\*(C`\-\-config\*(C'\fR) options must be the same as for the target daemon. .ie n .IP "\*(C`\-\-restart\*(C'" 4 .el .IP "\f(CW\*(C`\-\-restart\*(C'\fR" 4 .IX Item "--restart" Instruct a named daemon to terminate and restart its client process, by sending it a \f(CW\*(C`SIGUSR1\*(C'\fR signal. This will cause the named daemon to send its client process a \f(CW\*(C`SIGTERM\*(C'\fR signal to stop it. If the named daemon had been started with the \f(CW\*(C`\-\-restart\*(C'\fR option, the named daemon will then restart its client process. Otherwise, this has the same effect as the \f(CW\*(C`\-\-stop\*(C'\fR option, and the named daemon's client process is not restarted. .Sp This option can only be used with the \f(CW\*(C`\-\-name\*(C'\fR option. Note that the \&\f(CW\*(C`\-\-chroot\*(C'\fR, \f(CW\*(C`\-\-user\*(C'\fR, \f(CW\*(C`\-\-name\*(C'\fR, \f(CW\*(C`\-\-pidfiles\*(C'\fR and \f(CW\*(C`\-\-pidfile\*(C'\fR (and possibly \f(CW\*(C`\-\-config\*(C'\fR) options must be the same as for the target daemon. .ie n .IP "\*(C`\-\-stop\*(C'" 4 .el .IP "\f(CW\*(C`\-\-stop\*(C'\fR" 4 .IX Item "--stop" Stop a named daemon by sending it a \f(CW\*(C`SIGTERM\*(C'\fR signal. This will cause the named daemon to send its client process a \f(CW\*(C`SIGTERM\*(C'\fR option and then exit. .Sp This option can only be used with the \f(CW\*(C`\-\-name\*(C'\fR option. Note that the \&\f(CW\*(C`\-\-chroot\*(C'\fR, \f(CW\*(C`\-\-user\*(C'\fR, \f(CW\*(C`\-\-name\*(C'\fR, \f(CW\*(C`\-\-pidfiles\*(C'\fR and \f(CW\*(C`\-\-pidfile\*(C'\fR (and possibly \f(CW\*(C`\-\-config\*(C'\fR) options must be the same as for the target daemon. .ie n .IP "\*(C`\-\-signal=\*(C'\fIsigname\fR" 4 .el .IP "\f(CW\*(C`\-\-signal=\*(C'\fR\fIsigname\fR" 4 .IX Item "--signal=signame" Send the given signal to a named daemon's client process. The signal can be specified either by number or by name (with or without the \*(L"sig\*(R" prefix). Any signal may be sent. However, the named daemon's client process might be ignoring some signals. For example, \f(CW\*(C`SIGHUP\*(C'\fR will be ignored by default unless the client process has installed a signal handler for it. .Sp The known list of signals are: \f(CW\*(C`hup\*(C'\fR, \f(CW\*(C`int\*(C'\fR, \f(CW\*(C`quit\*(C'\fR, \f(CW\*(C`ill\*(C'\fR, \f(CW\*(C`trap\*(C'\fR, \&\f(CW\*(C`abrt\*(C'\fR, \f(CW\*(C`iot\*(C'\fR, \f(CW\*(C`bus\*(C'\fR, \f(CW\*(C`fpe\*(C'\fR, \f(CW\*(C`kill\*(C'\fR, \f(CW\*(C`usr1\*(C'\fR, \f(CW\*(C`segv\*(C'\fR, \f(CW\*(C`usr2\*(C'\fR, \&\f(CW\*(C`pipe\*(C'\fR, \f(CW\*(C`alrm\*(C'\fR, \f(CW\*(C`term\*(C'\fR, \f(CW\*(C`stkflt\*(C'\fR, \f(CW\*(C`cld\*(C'\fR, \f(CW\*(C`chld\*(C'\fR, \f(CW\*(C`cont\*(C'\fR, \f(CW\*(C`stop\*(C'\fR, \&\f(CW\*(C`tstp\*(C'\fR, \f(CW\*(C`ttin\*(C'\fR, \f(CW\*(C`ttou\*(C'\fR, \f(CW\*(C`urg\*(C'\fR, \f(CW\*(C`xcpu\*(C'\fR, \f(CW\*(C`xfsz\*(C'\fR, \f(CW\*(C`vtalrm\*(C'\fR, \f(CW\*(C`prof\*(C'\fR, \&\f(CW\*(C`winch\*(C'\fR, \f(CW\*(C`poll\*(C'\fR, \f(CW\*(C`io\*(C'\fR, \f(CW\*(C`pwr\*(C'\fR, \f(CW\*(C`sys\*(C'\fR, \f(CW\*(C`emt\*(C'\fR and \f(CW\*(C`info\*(C'\fR. Not all of them are available on all platforms. .ie n .IP "\*(C`\-\-list\*(C'" 4 .el .IP "\f(CW\*(C`\-\-list\*(C'\fR" 4 .IX Item "--list" Print a list of the currently running named daemons whose pidfiles are in the applicable pidfile directory which will either be the default (i.e. \&\f(CW\*(C`/var/run\*(C'\fR for \fIroot\fR (\f(CW\*(C`/etc\*(C'\fR on \fISolaris\fR, \f(CW\*(C`/opt/local/var/run\*(C'\fR on \&\fImacOS\fR when installed via \fImacports\fR), and \f(CW\*(C`/tmp\*(C'\fR for normal users), or it will be specified by the \f(CW\*(C`\-\-pidfiles\*(C'\fR option. Then exit. .Sp Without the \f(CW\*(C`\-\-verbose\*(C'\fR option, this will only list the names of daemons whose pidfiles are locked, as this implies that the corresponding daemon must still be running. Note that pidfiles for daemons that were not started by \fI\f(BIdaemon\fI\|(1)\fR might not be locked. An unlocked pidfile might indicate that \&\fI\f(BIdaemon\fI\|(1)\fR has died unexpectedly, or it might just be a pidfile for a daemon that was not started by \fI\f(BIdaemon\fI\|(1)\fR. If this might lead to confusion, you might want to consider using a dedicated pidfiles directory for named daemons started by \fI\f(BIdaemon\fI\|(1)\fR, and leave the default pidfiles directories for other daemons that were started independently of \&\fI\f(BIdaemon\fI\|(1)\fR. .Sp With the \f(CW\*(C`\-\-verbose\*(C'\fR option, the items in the list will look like the output of the \f(CW\*(C`\-\-running\*(C'\fR option with \f(CW\*(C`\-\-verbose\*(C'\fR, but with more detail. .Sp If there are no pidfiles at all, the output will look like this: .Sp .Vb 1 \& No named daemons are running .Ve .Sp If a pidfile is locked, and there is a corresponding client pidfile, that indicates that the named daemon and its client are both running, and the output will look like this, showing both process IDs: .Sp .Vb 1 \& name is running (pid ####) (client pid ####) .Ve .Sp If a pidfile is locked, but there is no client pidfile, that indicates that the named daemon is running, but its client is not (e.g. during a delay between respawn attempt bursts when the client is failing to start successfully), and the output will look like one of the following three options: .Sp When we can tell that the pidfile is for a process whose executable name is \&\fIdaemon\fR: .Sp .Vb 1 \& name is running (pid ####) (client is not running) .Ve .Sp When we can tell that the pidfile is for a process whose executable name is something other than \fIdaemon\fR (i.e. is independent of \fI\f(BIdaemon\fI\|(1)\fR): .Sp .Vb 1 \& name is running (pid ####) (independent) .Ve .Sp When it's not possible to determine the name of the executable associated with the \fIpidfile\fR (i.e. On systems other than \fILinux\fR without a \f(CW\*(C`/proc\*(C'\fR file system): .Sp .Vb 1 \& name is running (pid ####) (client is not running or is independent) .Ve .Sp If a pidfile is not locked, and the applicable pidfiles directory is the default, that indicates either that the daemon has unexpectedly terminated, or just that the pidfile is for a daemon that was not started by \&\fI\f(BIdaemon\fI\|(1)\fR, and the output will look like this: .Sp .Vb 1 \& name is not running (or is independent) .Ve .Sp If a pidfile is not locked, and the applicable pidfiles directory is not the default, then it is assumed that all pidfiles are for daemons that were started by \fI\f(BIdaemon\fI\|(1)\fR, and the output will look like this: .Sp .Vb 1 \& name is not running .Ve .PP As with all other programs, a \f(CW\*(C`\-\-\*(C'\fR argument signifies the end of options. Any options that appear on the command line after \f(CW\*(C`\-\-\*(C'\fR are part of the client command. .SH "EXPANSION" .IX Header "EXPANSION" Some simple shell-like expansion is performed internally on the arguments of the command line options with a text argument (but not the options with a numeric argument). .PP Environment variable notation, such as \f(CW$VAR\fR or \f(CW\*(C`${VAR}\*(C'\fR, is expanded. Then user home directory notation, such as \f(CW\*(C`~\*(C'\fR or \f(CW\*(C`~user\*(C'\fR, is expanded. File name expansion (i.e. globbing) is \s-1NOT\s0 performed internally. Neither are any of your login shell's other wonderful expansions. This is very basic. .PP This might not be of much use on the command line, since \fIdaemon\fR is normally invoked via a shell, which will first perform all of its usual expansions. It might even be undesirable to perform expansion internally after the shell has already done so (e.g. if you refer to any directory names that actually contain the \f(CW\*(Aq$\*(Aq\fR character, or if you use any environment variables whose values contain the \f(CW\*(Aq$\*(Aq\fR character, which is unlikely). .PP But it can be useful in configuration files. See the \f(CW\*(C`FILES\*(C'\fR section below for more details. It can also be useful when \fIdaemon\fR is invoked directly by another program without the use of a shell. .PP By default, environment variable expansion is not performed for the \fIroot\fR user, even if the environment variable was defined in the configuration files. The \f(CW\*(C`\-\-idiot\*(C'\fR option can be used to change this behaviour, and allow the expansion of environment variables for the \fIroot\fR user. Home directory notation expansion is performed for all users. .SH "FILES" .IX Header "FILES" \&\f(CW\*(C`/etc/daemon.conf\*(C'\fR, \f(CW\*(C`/etc/daemon.conf.d/*\*(C'\fR \- system-wide default options .PP \&\f(CW\*(C`/usr/local/etc/daemon.conf\*(C'\fR, \f(CW\*(C`/usr/local/etc/daemon.conf.d/*\*(C'\fR \- system-wide default options on \fI\s-1BSD\s0\fR systems (except \fImacOS\fR). .PP \&\f(CW\*(C`/opt/local/etc/daemon.conf\*(C'\fR, \f(CW\*(C`/opt/local/etc/daemon.conf.d/*\*(C'\fR \- system-wide default options on \fImacOS\fR when installed via \fImacports\fR. .PP \&\f(CW\*(C`~/.daemonrc\*(C'\fR, \f(CW\*(C`~/.daemonrc.d/*\*(C'\fR \- user-specific default options .PP Each line of the configuration file is either an environment variable definition, or a configuration directive. .PP Environment variable definitions consist of the variable name, followed immediately by \f(CW\*(Aq=\*(Aq\fR and the value of the variable. They look like they do in shell, except that there is no quoting or other shell syntax. Environment variable values can include simple environment variable notation (e.g. \&\f(CW$VAR\fR or \f(CW\*(C`${VAR}\*(C'\fR), and user home directory notation (e.g. \f(CW\*(C`~\*(C'\fR or \&\f(CW\*(C`~user\*(C'\fR). These will be expanded internally by \fIdaemon\fR. See the \&\f(CW\*(C`EXPANSION\*(C'\fR section above for more details. .PP Note that any environment variables that are defined in the configuration file, which are subsequently used explicitly in another environment variable definition or in an option argument, will have these expansions performed multiple times. Avoid environment variables whose values can change again if expansion is performed multiple times. .PP Example: .PP .Vb 2 \& PATH=/usr/bin:/usr/sbin:$HOME/bin:~app/bin \& PIDFILES=~/.run .Ve .PP Configuration directives consist of a client name (for options that apply to a single client), or \f(CW\*(Aq*\*(Aq\fR (for generic options that apply to all clients), followed by spaces and/or tabs, followed by a comma-separated list of options. Any option arguments must not contain any commas. The commas that separate options can have spaces and tabs before and after them. Option arguments that are text (but not numbers) can include simple environment variable notation (e.g. \f(CW$VAR\fR or \f(CW\*(C`${VAR}\*(C'\fR), and user home directory notation (e.g. \f(CW\*(C`~\*(C'\fR or \f(CW\*(C`~user\*(C'\fR). These will be expanded internally by \&\fIdaemon\fR. See the \f(CW\*(C`EXPANSION\*(C'\fR section above for more details. .PP Blank lines and comments (\f(CW\*(Aq#\*(Aq\fR to end of the line) are ignored. Lines can be continued with a \f(CW\*(Aq\e\*(Aq\fR character at the end of the line. .PP Example: .PP .Vb 5 \& * errlog=daemon.err,output=local0.err,core \& test1 syslog=local0.debug,debug=9,verbose=9,respawn \& test2 syslog=local0.debug,debug=9, \e \& verbose=9,respawn, \e \& pidfiles=$PIDFILES .Ve .PP The command line options are processed first, to look for a \f(CW\*(C`\-\-config\*(C'\fR option. If no \f(CW\*(C`\-\-config\*(C'\fR option was supplied, the default configuration files, \f(CW\*(C`/etc/daemon.conf\*(C'\fR and \f(CW\*(C`/etc/daemon.conf.d/*\*(C'\fR, are used. On \fI\s-1BSD\s0\fR systems (except \fImacOS\fR), the default configuration files are \&\f(CW\*(C`/usr/local/etc/daemon.conf\*(C'\fR and \f(CW\*(C`/usr/local/etc/daemon.conf.d/*\*(C'\fR. On \&\fImacOS\fR when installed via \fImacports\fR, the default configuration files are \&\f(CW\*(C`/opt/local/etc/daemon.conf\*(C'\fR and \f(CW\*(C`/opt/local/etc/daemon.conf.d/*\*(C'\fR. If the user has their own configuration files, \f(CW\*(C`~/.daemonrc\*(C'\fR and \&\f(CW\*(C`~/.daemonrc.d/*\*(C'\fR, they are also used. .PP If the configuration files contain any generic (\f(CW\*(Aq*\*(Aq\fR) entries, their options are applied in order of appearance. If the \f(CW\*(C`\-\-name\*(C'\fR option was supplied, and the configuration files contain any entries for the given name, those options are then applied in order of appearance. .PP Finally, the command line options are applied again. This ensures that any generic options apply to all clients by default. Client-specific options override generic options. User options override system-wide options. Command line options override everything else. .PP Note that the configuration files are not opened and read until after any \&\f(CW\*(C`\-\-chroot\*(C'\fR and/or \f(CW\*(C`\-\-user\*(C'\fR command line options are processed. This means that the configuration file paths and the client's file path must be relative to the \f(CW\*(C`\-\-chroot\*(C'\fR argument. It also means that the configuration files and the client executable must be readable/executable by the user specified by the \f(CW\*(C`\-\-user\*(C'\fR argument. It also means that the \f(CW\*(C`\-\-chroot\*(C'\fR and \&\f(CW\*(C`\-\-user\*(C'\fR options must not appear in the configuration file. Also note that the \f(CW\*(C`\-\-name\*(C'\fR option must not appear on the right hand side in the configuration file either. .SH "MESSAGING" .IX Header "MESSAGING" The \f(CW\*(C`\-\-errlog\*(C'\fR, \f(CW\*(C`\-\-dbglog\*(C'\fR, \f(CW\*(C`\-\-output\*(C'\fR, \f(CW\*(C`\-\-stdout\*(C'\fR and \f(CW\*(C`\-\-stderr\*(C'\fR options all take an argument that can be either a syslog destination of the form \f(CW"facility.priority"\fR or the path to a file. Here are the lists of syslog facilities and priorities: .PP .Vb 3 \& Facilities: \& kern, user, mail, daemon, auth, syslog, lpr, news, uucp, cron, \& local0, local1, local2, local3, local4, local5, local6, local7. \& \& Priorities: \& emerg, alert, crit, err, warning, notice (on some systems), info, debug. .Ve .PP If the path to a file is supplied instead, bear in mind the fact that \&\fI\f(BIdaemon\fI\|(1)\fR changes to the root directory by default, and so the file path should be an absolute path (or relative to the \f(CW\*(C`\-\-chroot\*(C'\fR and/or \f(CW\*(C`\-\-chdir\*(C'\fR option argument). Otherwise, \fI\f(BIdaemon\fI\|(1)\fR will attempt to create the file relative to its current directory. You might not have permissions to do that, or want to even if you do. .SH "CAVEAT" .IX Header "CAVEAT" Clients can only be restarted if they were started with the \f(CW\*(C`\-\-respawn\*(C'\fR option. Using \f(CW\*(C`\-\-restart\*(C'\fR on a non-respawning daemon client is equivalent to using \f(CW\*(C`\-\-stop\*(C'\fR. If you try to restart a named daemon, and it stops instead, then it probably wasn't started with the \f(CW\*(C`\-\-respawn\*(C'\fR option. .PP Clients that are run in the foreground with a pseudo terminal don't respond to job control (i.e. suspending with Control-Z doesn't work). This is because the client belongs to an orphaned process group (it starts in its own process session), so the kernel won't send it \f(CW\*(C`SIGSTOP\*(C'\fR signals. However, if the client is a shell that supports job control, then its subprocesses can be suspended. .PP In \s-1KDE,\s0 if you use \f(CW"exec daemon"\fR (or just \f(CW"exec"\fR without \f(CW\*(C`daemon\*(C'\fR) in a shell, to run a \s-1KDE\s0 application, you might find that the \s-1KDE\s0 application sometimes doesn't run. This problem has only been seen with \fI\f(BIkonsole\fI\|(1)\fR, but it might happen with other \s-1KDE\s0 applications as well. Capturing the standard error of the \s-1KDE\s0 application might show something like: .PP .Vb 4 \& unnamed app(9697): KUniqueApplication: Registering failed! \& unnamed app(9697): Communication problem with "konsole" , it probably crashed. \& Error message was: "org.freedesktop.DBus.Error.ServiceUnknown" : " "The name \& org.kde.konsole was not provided by any .service files" .Ve .PP A workaround seems to be to delay the termination of the initial \&\fI\f(BIdaemon\fI\|(1)\fR process by at least 0.4 seconds. To make this happen, set the environment variable \f(CW\*(C`DAEMON_INIT_EXIT_DELAY_MSEC\*(C'\fR to the number of milliseconds by which to delay. For example: \&\f(CW\*(C`DAEMON_INIT_EXIT_DELAY_MSEC=400\*(C'\fR. Or you could just avoid using \f(CW\*(C`exec\*(C'\fR when starting \fI\s-1KDE\s0\fR applications. .PP On \fILinux\fR systems that have \fI\f(BIsystemd\fI\|(1)\fR or \fI\f(BIelogind\fI\|(8)\fR, you might find that your \fIdaemon\fR processes and their client processes are terminated when you logout, even though they are in a different process session, and so should be unaffected. This is because \fIsystemd\fR has the ability to terminate all of your processes when you logout. Luckily, this feature is turned off by default in some \fILinux\fR distributions. However, if it is on, you can turn it off by adding the following line to \&\f(CW\*(C`/etc/systemd/logind.conf\*(C'\fR (or \f(CW\*(C`/etc/elogind/logind.conf\*(C'\fR): .PP .Vb 1 \& KillUserProcesses=no .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fI\f(BIlibslack\fI\|(3)\fR, \&\fI\f(BIdaemon\fI\|(3)\fR, \&\fI\f(BIcoproc\fI\|(3)\fR, \&\fI\f(BIpseudo\fI\|(3)\fR, \&\fI\f(BIinit\fI\|(8)\fR, \&\fI\f(BIinetd\fI\|(8)\fR, \&\fI\f(BIfork\fI\|(2)\fR, \&\fI\f(BIumask\fI\|(2)\fR, \&\fI\f(BIsetsid\fI\|(2)\fR, \&\fI\f(BIchdir\fI\|(2)\fR, \&\fI\f(BIchroot\fI\|(2)\fR, \&\fI\f(BIsetrlimit\fI\|(2)\fR, \&\fI\f(BIsetgid\fI\|(2)\fR, \&\fI\f(BIsetuid\fI\|(2)\fR, \&\fI\f(BIsetgroups\fI\|(2)\fR, \&\fI\f(BIinitgroups\fI\|(3)\fR, \&\fI\f(BIsyslog\fI\|(3)\fR, \&\fI\f(BIkill\fI\|(2)\fR, \&\fI\f(BIwait\fI\|(2)\fR, \&\fI\f(BIsystemd\-logind\fI\|(8)\fR, \&\fI\f(BIelogind\fI\|(8)\fR .SH "AUTHOR" .IX Header "AUTHOR" 20230824 raf