最佳实践:unix 守护进程的 PID 文件
Best practice: PID file for unix daemon
是否认为 Unix 守护进程的父进程或子进程写入 PID 文件(对于子进程)是最佳实践。
实际的守护进程(子进程)。
根据 systemd
软件包提供的 daemon
手册页,运行 man daemon
可在 RHEL 7(或 CentOS 7)主机上查看:
- In the daemon process, write the daemon PID (as returned by getpid())
to a PID file, for example /run/foobar.pid (for a hypothetical daemon
"foobar") to ensure that the daemon cannot be started more than once.
This must be implemented in race-free fashion so that the PID file is
only updated when it is verified at the same time that the PID
previously stored in the PID file no longer exists or belongs to a
foreign process.
您还可以阅读手册页 on the internet。
是否认为 Unix 守护进程的父进程或子进程写入 PID 文件(对于子进程)是最佳实践。
实际的守护进程(子进程)。
根据 systemd
软件包提供的 daemon
手册页,运行 man daemon
可在 RHEL 7(或 CentOS 7)主机上查看:
- In the daemon process, write the daemon PID (as returned by getpid()) to a PID file, for example /run/foobar.pid (for a hypothetical daemon "foobar") to ensure that the daemon cannot be started more than once. This must be implemented in race-free fashion so that the PID file is only updated when it is verified at the same time that the PID previously stored in the PID file no longer exists or belongs to a foreign process.
您还可以阅读手册页 on the internet。