NAME

daemon - turns other processes into daemons


SYNOPSIS

 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 debug level

   -n, --name=name                - Name the client exclusively
   -u, --user=user[.group]        - Run the client as user[.group]
   -r, --respawn                  - Respawn the client
   -c, --core                     - Allow core file generation
   -s, --syslog=facility.priority - Send client's output to syslog
   -l, --log=facility.priority    - Send daemon's output to syslog
   -C, --config=path              - Specify the configuration file


DESCRIPTION

Daemon 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. Daemon performs these tasks for other processes.

The preparatory tasks that daemon performs for other processes are:

Daemon then spawns the client command specified on its command line and waits for it to terminate. If the --user option is supplied, daemon changes the user id and group id of the client process. Only root can use this option. If the --syslog option is supplied, the client's standard output and error are captured by daemon and sent to the syslog destination specified in the --syslog option.

When the client terminates, daemon respawns it if the --respawn option is supplied and the client terminated successfully after at least 600 seconds. Otherwise daemon terminates.

If daemon receives a SIGTERM signal, it propagates the signal to the client and then terminates.

Note: For security reasons, never install daemon with setuid or setgid privileges. It is unnecessary. If you do, daemon will revert to the real user and group for safety before doing anything else.


OPTIONS

-h, --help

Display a help message and exit.

-V, --version

Display a version message and exit.

-v[level], --verbose[=level]

Set the message verbosity level to level (or 1 if level is not supplied). daemon does not have any verbose messages so this has no effect.

-d[level], --debug[=level]

Set the debug message level to level (or 1 if level is not supplied). Set to level 1 for a trace of all functions called. Set to level 2 for more detail. Debug messages are sent to the syslog(3) facility, daemon.debug.

-n=name, --name=name

Create and lock a pid file (/var/run/name.pid), ensuring that only one daemon with the given name is active at the same time.

-u=user[.group], --user=user[.group]

Run the client as a different user (and group). This only works for root.

-r, --respawn

Respawn the client when it terminates successfully after at least 600 seconds.

-c, --core

Allow the client to create a core file. This should only be used for debugging as it could lead to security holes in daemons run by root.

-s=facility.priority --syslog=facility.priority

Capture the client's standard output and error and send it to the syslog destination specified by facility.priority.

-l=facility.priority --log=facility.priority

Send daemon's standard output and error to the syslog destination specified by facility.priority. By default, they are sent to daemon.err.

-C=path, --config=path

Specify the configuration file to use. By default, /etc/daemon.conf is the 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.


FILES

/etc/daemon.conf - define default options

Each line of the configuration file consists of a client name or `*', followed by whitespace, followed by a comma separated list of options. Blank lines and comments (`#' to end of the line) are ignored. Lines may be continued with a `\' character at the end of the line.

For example:

    *       log=daemon.err,syslog=local0.err,respawn
    test1   syslog=local0.debug,debug=9,verbose=9,core
    test2   syslog=local0.debug,debug=9,verbose=9,core

The command line options are processed first to look for a --config option. If no --config option is supplied, the default file, /etc/daemon.conf, is used. If the configuration file contains any generic (`*') entries, their options are applied in order of appearance. If the --name option is supplied and the configuration file contains any entries with the given name, their options are then applied in order of appearance. 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. Command line options override both.


BUGS

You can't specify one syslog destination for the client's standard output and a different one for its standard error.

You can't use spaces in client names in the configuration file.

If you specify (in the configuration file) that all clients allow core file generation, there is no way to countermand that for any client (without using an alternative configuration file). So don't do that. The same applies to respawning but that shouldn't be problem.

It is possible for the client process to obtain a controlling terminal under BSD (and even under SVR4 if SVR4 was not defined or NO_EXTRA_SVR4_FORK was defined when libslack is compiled). If anything calls open(2) on a terminal device without the O_NOCTTY flag, the process doing so will obtain a controlling terminal and then be susceptible to termination by a SIGHUP.


MAILING LISTS

The following mailing lists exist for daemon related discussion:

 daemon-announce@libslack.org - Announcements
 daemon-users@libslack.org    - User forum
 daemon-dev@libslack.org      - Development forum

To subscribe to any of these mailing lists, send a mail message to listname-request@libslack.org with subscribe as the message body. e.g.

 $ echo subscribe | mail daemon-announce-request@libslack.org
 $ echo subscribe | mail daemon-users-request@libslack.org
 $ echo subscribe | mail daemon-dev-request@libslack.org

Or you can send a mail message to majordomo@libslack.org with subscribe listname in the message body. This way, you can subscribe to multiple lists at the same time. e.g.

 $ mail majordomo@libslack.org
 subscribe daemon-announce
 subscribe daemon-users
 subscribe daemon-dev
 .

A digest version of each mailing list is also available. Subscribe to digests as above but append -digest to the listname.


SEE ALSO

libslack(3), daemon(3), init(8), inetd(8)


AUTHOR

20010215 raf <raf@raf.org>