Three kinds of processes-orphan process, zombie process, daemon process

Three processes

Orphan process

  • Orphan process : A parent process exits while one or more of its child processes are still running, then those child processes will become orphan processes. The orphan process is adopted by the init process (process number is 1), and the init process completes the state collection work for them.

Zombie process

  • Zombie process : A process uses fork to create a child process. If the child process exits and the parent process does not call wait or waitpid to obtain the status information of the child process, the process descriptor of the child process is still stored in the system. This kind of process is called a zombie process.

Daemon

  • Daemon : A program that executes in the background. Such programs will be initialized in the form of processes . The name of a daemon program usually ends with the letter "d". For example, syslogd is a daemon that manages system logs.

Need to pay attention to

  • In the Linux system, whenever an orphan process appears , the kernel sets the parent process of the orphan process to init, and the init process calls wait() in a loop to process the child process that has exited. In this way, when an orphaned process ends its life cycle bleakly, the init process will handle all its aftermath as a shelter. Therefore, the orphan process is not harmful.
  • For zombie processes , if the process does not call wait/waitpid, the reserved information will not be released, and its process ID will always be occupied, but the process ID that the system can use is limited. If a large number of them are generated A dead process will cause the system to fail to generate a new process because there is no available process number. This is the harm of zombie processes and should be avoided .
  • The solution to the zombie process : The zombie process is not the root cause of the problem. The culprit is the parent process that produces a large number of zombie processes. Therefore, when we want to eliminate a large number of zombie processes in the system, what we have to do is kill the parent process that produced a large number of zombie processes (by sending SIGTERM or SIGKILL signals through kill) . After killing, the resulting zombie processes become orphan processes, and these orphan processes will be taken over by the init process.

Guess you like

Origin blog.csdn.net/qq_41782149/article/details/106113611