守护进程和孤儿进程之间的区别?

Difference between a Daemon process and an orphan process?

我对守护进程和孤儿进程感到困惑。据我了解:

Daemon Process: "These are special processes that run in background. They are system related process that have no associated terminal.These processes run with root permissions and usually provide services to processes.Usually parent process will terminates and hence child process will become a daemon process as it wont have any terminal.For daemon process, init process will become a parent process"

Orphan Process: "when parent process gets killed before child process terminates, then that process becomes an orphan process. In that case the child processes become orphan and then taken under by the init process."

孤儿进程是守护进程,反之亦然吗?如果不是,它们之间的基本区别是什么?

一个并不严格暗示另一个: 只需将守护进程视为 有意孤立的进程 。 它们旨在在没有父进程的情况下工作,但这并不适用于每个孤立进程!

It is sometimes desirable to intentionally orphan a process, usually to allow a long-running job to complete without further user attention, or to start an indefinitely running service or agent; such processes (without an associated session) are known as daemons, particularly if they are indefinitely running

只要把守护进程想象成 "slaves" 干脏活的人:你故意把它们放在你看不见的地方,但并不是所有离开你视线的东西都是有意或特别想要的 ;)

我认为在这种情况下,维基百科足以满足您的困境:https://en.wikipedia.org/wiki/Orphan_process

我同意 Defrag 的回答。我只想提一下,守护进程不一定 运行 作为 root。事实上,出于安全原因,最好不要 运行 某些守护进程作为 root,例如 Web 服务器进程或数据库侦听器进程。如果守护程序存在安全问题,这会限制您的暴露。

此外,用户自己可以编写 运行 作为守护进程的程序。