Three special process: orphaned, zombie processes and daemons.

1. orphaned

If the parent process exits first, not the child process exits, the child process will be Tuogu to the init process, which is the parent of the child process is the init process (process 1)

2. zombie process

Linux process state and the conversion relationship, we should know the process so many states there is one state is dead state, that is, after the process terminates into the dead state (zombie), waiting to inform himself terminates the parent process, before you can completely disappear.

However, if a process has been terminated, but the parent process has not yet acquired its status, then this process it is called a zombie process. Zombie process will consume some system resources, and also keep some summary information for the parent process child process queries the state can provide information about the parent wants. Once the parent process to get the information you want, zombie process will end

3. Daemon

Daemon is running in the background, without any process associated with the terminal, usually daemons to run at system startup, they (apache and postfix) as root or other special users, and can deal with some system-level task name daemon on the practice usually ends in d (sshd), but these are not required.

Here are some steps to create a daemon:

Calls fork (), create a new process, it would be the future of the daemon.
Call exit in the parent process to ensure that the child is not a process group leader
calls setsid () to create a new conversation area
will change the current directory with the directory (if current directory as the directory daemon, the current working directory to the directory can not be uninstalled him as daemon)
standard input, output mark, the standard error is redirected to / dev / null

reference

https://www.cnblogs.com/wannable/p/6021617.html

Published 137 original articles · won praise 44 · views 30000 +

Guess you like

Origin blog.csdn.net/qq_38769551/article/details/105150315