ps -eo ppid,pid,sid,stat,tty,comm | awk '{ if ($2 == $3 && $5 == "?") {print $0}; }'
首先,要注意,守护进程(daemon)和后台进程(background process)有区别。
守护进程是一种后台进程,但是,同时,它必须具备以下特性:
1. 没有控制它的tty
2. 必须是一个session leader
3. 必须是一个进程组的leader
4. 执行后台任务
5. root目录即为工作目录
6. umask设置为0
7. 文件描述符(file descriptor)都必须先关闭,然后再关联相应文件(或者设备),如果有需要的话。
Wiki原文摘录如下:
On a Unix-like system, the common method for a process to become a daemon, when the process is started from the command line or from a startup script such as an init script or a