DAEMON(7) daemon DAEMON(7) NAME daemon - "" SysV Unix "" systemd(1) systemd SysV SysV 1. STDIN STDOUT STDERR 2. 3. 4. () 5. fork() 6. setsid() 7. fork() 8. () init(PID=1) 9. () STDIN STDOUT STDERR /dev/null 10. umask 0 11. (/) 12. PID /run/foobar.pid 13. () 14. 15. SysV Linux systemd (STDIN) /dev/null () (STDOUT)(STDERR) systemd- journald.service(8) ()umask ... 1. SIGTERM 2. SIGHUP () 3. LSB recommendations for SysV init scripts[1] systemd 4. D-Bus D-Bus 5. .service // systemd.service(5) 6. systemd (CPU/) systemd.exec(5) 7. D-Bus D-Bus () D-Bus() 8. () () ( syslog, DNS) () 9. sd_notify(3) systemd """" 10. syslog() fprintf() STDERR "<4>" (4"WARNING") sd- daemon(3) systemd.exec(5) Apple MacOS X Daemon Requirements[2] systemd () bluetoothd.service D-Bus IPP spool D-Bus D-Bus () D-Bus SysV systemd systemd ( multi-user.target graphical.target) .wants/ systemd.unit(5) .wants/ systemd.special(7) systemd systemd () ( DNS syslog ) systemd sd_listen_fds(3) sd-daemon(3) systemd .socket systemd.socket(5) socket sockets.target socket "[Install]" WantedBy=sockets.target DefaultDependencies=no socket sockets.target systemd.special(7) socket sockets.target ( multi-user.target ) D-Bus D-Bus D-Bus D-Bus D-Bus service () D-Bus systemd D-Bus service SystemdService= org.freedesktop.RealtimeKit.service D-Bus service rtkit-daemon.service SystemdService=rtkit-daemon.service SystemdService= // "systemd" sysfs/udev systemd device Wants= device () udev SYSTEMD_WANTS= systemd.device(5) service Wants= target bluetoothd.service Wants= bluetoothd.service bluetooth.target Wants= bluetooth.target Wants= bluetooth.target udev systemctl enable|disable ... bluetooth.target.wants/ bluetoothd.service spool () spool .path systemd.path(5) () .timer systemd.timer(5) SYSTEMD systemd 1. Type=forking PIDFile= systemd.service(5) 2. D-Bus Type=dbus 3. Description= 4. DefaultDependencies=yes 5. systemd.special(7) 6. "[Install]" ( systemd.unit(5) ) WantedBy=multi-user.target WantedBy=graphical.target WantedBy=sockets.target ( foo.service) Also=foo.socket service (make install) pkg-config systemd --variable=systemdsystemunitdir ( /usr/lib/systemd/system) pkg-config systemd --variable=systemduserunitdir ( /usr/lib/systemd/user) systemctl enable ... (rpm -i) systemctl enable ... systemd SysV systemd SysV ...[]... file-hierarchy(7) systemd(1), sd-daemon(3), sd_listen_fds(3), sd_notify(3), daemon(3), systemd.service(5), file-hierarchy(7) NOTES 1. LSB recommendations for SysV init scripts http://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core- generic/iniscrptact.html 2. Apple MacOS X Daemon Requirements https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html man http://www.jinbuguo.com man https://github.com/man-pages-zh/manpages- zh systemd 231 DAEMON(7)