README
======
*daemon* - turns other processes into daemons
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. This is useful for writing
daemons in languages other than *C*, *C++* or *Perl* (e.g. `/bin/sh`, *Java*).
If you want to write daemons in languages that can link against *C* functions
(e.g. *C*, *C++*), see *libslack* which contains the core functionality of *daemon*.
DETAILS
=======
*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:
First revoke any setuid or setgid privileges that *daemon* may have been
installed with (by system administrators who laugh in the face of danger).
Process command line options.
Change the root directory if the `--chroot` option was supplied.
Change the process `uid` and `gid` if the `--user` option was supplied. Only
*root* can use this option. Note that the `uid` of *daemon* itself is changed,
rather than just changing the `uid` of the client process.
Read the system configuration file(s) (`/etc/daemon.conf` and
`/etc/daemon.conf.d/*` by default, or specified by the `--config` option)
unless the `--noconfig` option was supplied. Then read the user's personal
configuration file(s) (`~/.daemonrc` and `~/.daemonrc.d/*`), if any. Note:
The root directory and the user must be set before access to the
configuration file(s) can be attempted so neither `--chroot` nor `--user`
options may appear in the configuration file.
On *BSD* systems (except *macOS*), the system configuration file(s) are
`/usr/local/etc/daemon.conf` and `/usr/local/etc/daemon.conf.d/*` by
default.
On *macOS*, when installed via *macports*, the system configuration file(s)
are `/opt/local/etc/daemon.conf` and `/opt/local/etc/daemon.conf.d/*`.
Disable core file generation to prevent leaking potentially sensitive
information in daemons that are run by *root* (unless the `--core` option
was supplied).
Become a daemon process:
* If *daemon* was not invoked by *init(8)* (i.e. pid 1) or *inetd(8)*:
* Ignore `SIGHUP` signals in case the current process session leader
terminates while attached to a controlling terminal, causing us to
receive a `SIGHUP` signal before we start our own process session below.
This can happen when *daemon* was invoked interactively via the shell
builtin `exec`. When this initial process terminates below, the terminal
emulator that invoked the shell also terminates, so *daemon* needs to
protect itself from that.
* Background the process to lose process group leadership.
* Start a new process session.
* Background the process again to lose process session leadership. Under
*SVR4* this prevents the process from ever gaining a controlling
terminal. This is only necessary under *SVR4*, but is always done for
simplicity. Note that ignoring `SIGHUP` 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 `SIGHUP` signal that is sent to all
processes in the process session's foreground process group, because
it inherited signal dispositions from the initial process.
* Change the current directory to the root directory so as not to hamper
umounts.
* Clear the *umask* to enable explicit file creation modes.
* Close all open file descriptors. If *daemon* was invoked by *inetd(8)*,
`stdin`, `stdout` and `stderr` are left open, because they are open to a
socket.
* Open `stdin`, `stdout` and `stderr` to `/dev/null`, in case something
requires them to be open. Of course, this is not done if *daemon* was
invoked by *inetd(8)*.
* If the `--name` option was supplied, create and lock a file containing the
process id of the *daemon* 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 `/var/run` for
*root* (`/etc` on *Solaris*, `/opt/local/var/run` on *macOS* when
installed via *macports*), and `/tmp` for normal users. If the
`--pidfiles` option was supplied, its argument specifies the directory
in which the pidfile will be placed. If the `--pidfile` option was
supplied, its argument specifies the name of the pidfile and the
directory in which it will be placed.
If the `--umask` option was supplied, set the *umask* to its argument, which
must be a valid three-digit octal mode. Otherwise, set the *umask* to `022`,
to prevent accidentally creating group- or world-writable files.
Set the current directory if the `--chdir` option was supplied.
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
`--command` option. If both the `--command` option and command line
arguments are present, the client command is the result of appending the
command line arguments to the argument of the `--command` option.
If the `--output`, `--stdout` and/or `--stderr` option were supplied, the client's
standard output and/or standard error are captured by *daemon*, and sent to the
respective *syslog* destinations.
When the client terminates, *daemon* respawns it if the `--respawn` option
was supplied. If the client ran for less than `300` seconds (or the value of
the `--acceptable` option), then *daemon* sees this as a failure. It will
attempt to restart the client up to five times (or the value of the
`--attempts` option), before waiting for `300` seconds (or the value of the
`--delay` option). This gives the system administrator the chance to correct
whatever is preventing the client from running successfully without
overloading system resources. If the `--limit` option was supplied, *daemon*
terminates after the specified number of respawn attempt bursts. The default
is zero, which means never give up, never surrender.
When the client terminates, and the `--respawn` option wasn't supplied,
*daemon* terminates as well.
If the `--foreground` option was supplied, the client process is run as a
foreground process, and is not turned into a daemon at all. If *daemon* is
connected to a terminal, then the client process will also be connected to
it. If *daemon* is not connected to a terminal, but the client needs to be
connected to a terminal, use the `--pty` option.
If the `--bind` option was supplied, on systems with *systemd-logind* or
*elogind*, the client process will be terminated when the user logs out.
The `--stop` option sends a `SIGTERM` signal to a currently running named
*daemon*, which causes it to terminate its client process (with a `SIGTERM`
signal), and to then terminate itself.
The `--restart` option sends a `SIGUSR1` signal to a currently running named
*daemon*, which causes it to terminate its client process (with a `SIGTERM`
signal). If the named *daemon* was started with the `--respawn` option, it
will then restart the client. Otherwise, it will terminate itself.
The `--signal` option sends a user-specified signal directly to a currently
running named *daemon*'s client process.
The `--running` option reports whether or not a given named *daemon* process
is currently running.
The `--list` option reports all the currently running named *daemon* processes.
--------------------------------------------------------------------------------
URL: http://libslack.org/daemon
URL: http://raf.org/daemon
GIT: https://github.com/raforg/daemon
Date: 20210304
Author: raf <raf@raf.org>
没有合适的资源?快使用搜索试试~ 我知道了~
daemon-0.8.tar.gz
需积分: 12 0 下载量 91 浏览量
2022-03-11
17:51:59
上传
评论
收藏 431KB GZ 举报
温馨提示
共220个文件
c:30个
h:28个
client:10个
daemon-0.8.tar.gz
资源详情
资源评论
资源推荐
收起资源包目录
daemon-0.8.tar.gz (220个子文件)
analyse-debug-locker 3KB
str.c 258KB
net.c 232KB
daemon.c 141KB
list.c 109KB
agent.c 102KB
snprintf.c 85KB
map.c 73KB
prog.c 67KB
coproc.c 56KB
daemon.c 51KB
getopt.c 47KB
mem.c 44KB
msg.c 43KB
locker.c 38KB
prop.c 37KB
link.c 35KB
pseudo.c 33KB
err.c 31KB
fio.c 28KB
lim.c 19KB
sig.c 16KB
vsscanf.c 16KB
hsort.c 12KB
test13.daemon.c 2KB
test_logind.c 1KB
test15.client.c 369B
test63.client.c 264B
test58.client.c 227B
test6.client.c 83B
test5.client.c 83B
ccenv 1KB
ccenv 1024B
CHANGELOG 24KB
CHANGELOG 18KB
check-examples 2KB
check-pod 210B
check-pod-header 2KB
check-pod-prototypes 2KB
check-pod-synopsis 2KB
clean 341B
test2.client 80B
test1.client 79B
test3.client 69B
test18.client 50B
test4.client 42B
test17.client 39B
test16.client 39B
test8.client 30B
test7.client 22B
test9.client 22B
test13.compile 358B
daemon.conf 2KB
configure 4KB
configure 3KB
COPYING 3KB
COPYING 3KB
destdir 1KB
freebsd 7KB
freebsd 7KB
gnuhurd 7KB
gnuhurd 7KB
str.h 16KB
list.h 8KB
net.h 7KB
config.h 6KB
getopt.h 6KB
map.h 5KB
prog.h 5KB
locker.h 4KB
msg.h 3KB
agent.h 3KB
err.h 3KB
mem.h 3KB
daemon.h 2KB
pseudo.h 2KB
std.h 2KB
socks.h 2KB
lim.h 2KB
link.h 2KB
fio.h 2KB
prop.h 2KB
coproc.h 2KB
lib.h 1KB
sig.h 1KB
hsort.h 1KB
config.h 1KB
snprintf.h 1KB
hdr.h 1023B
vsscanf.h 998B
.ignored 40B
daemon.initd 4KB
INSTALL 10KB
INSTALL 9KB
kfreebsd 7KB
kfreebsd 7KB
LICENSE 18KB
LICENSE 18KB
linux 8KB
linux 7KB
共 220 条
- 1
- 2
- 3
Heart&Fire
- 粉丝: 15
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 20220823-1000-ts.dat
- Galaxy10CNN实现星系图像分类项目深度学习环境配置
- DVB-S2:GCS组帧数据.dat
- numpy+pandas_basics.ipynb
- 网络安全-Diffie Hellman密钥协商
- 双H桥电机驱动L298N芯片AD集成库ALTIUM库(原理图库+PCB封装库)文件.zip
- 555springboot + vue 线上教学平台.zip(可运行源码+数据库文件+文档)
- 554springcloud + vue 房产销售平台.zip(可运行源码+数据库文件+文档)
- 小霸王坦克游戏源码.7z
- 蓝桥杯单片机基础学习项目(LED,数码管,蜂鸣器,继电器,按键控制)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0