Zombie process orphaned

When a process terminates complete its work, its parent to call wait () or waitpid () to obtain termination status of the child process. If the process does not call wait / waitpid, then that piece of process information system reserves will not release its process ID would have been occupied, but the process ID system that can be used is limited, if a large number of zombies on, the number is not available because the process which led to the system can not produce a new process.

Orphan processes: a parent process to exit, but it's one or more child process is still running, so that the child will become orphaned. Orphan process will be init process (process 1) the adoption by the init process completion status of collection to them.

Orphan process is no parent process, the process that orphans init process falls on the body, put the parent kernel process is set to orphans init, and init process cycle to wait () has withdrawn its child processes. Thus, when a miserable orphan process ended its life cycle time, so orphans do not have any harm.

Linux kernel allows a process to obtain a query execution state of the parent PID, or any child processes. For example, the process can create a child process to perform a specific task, then call the library functions such as checking whether the child process so wait () / waitpid () terminates. If the child process has been terminated, then its parent process termination code will tell whether this task has been successfully completed.

In keeping with these design principles, the Linux kernel allowed discarded after a termination process comprising data symbols field in the process described. Only the parent process issues associated with the process is terminated wait () system call after class, will be allowed to do so. This is why the introduction of zombie state: although technically the process is dead, but it must be kept descriptors, until the parent calls to be notified.

If a process has been terminated, but it's not called the parent process wait () or waitpid () to handle it, then the process status is called dead state, in a state of process is called dead zombie process, under normal circumstances, zombies processes are immediately cleaned up the parent process.

How zombie process is generated

On UNIX systems, a process is over, but its parent is not waiting (call wait / waitpid) it, it will turn into a zombie process. By ps command to view its mark with the defunct. Zombie process is a long-end of the process, but still a position (slot) in the process table (process table) in.

However, if the parent process has already begun the process is over, then the process will not become a zombie process. Since the end of each process, the system will scan all processes currently running on the system to see if there is a child process which process just concluded this process, and if so, have the init process to take it over, it's called The parent process to ensure each process will have a parent process. The init process will automatically wait their child processes, so that all processes are taken over by init will not become a zombie process.

Only wait a sub-process and final delivery system process table they occupied in the number of resources and processes, so that these dead orphans process will be completely cleared.

Zombie process: a process using a fork to create a child process, if the child process exits, and the parent does not call wait or waitpid get child process status information, then the child process descriptor (PCB) is still stored in the system. This process is called a zombie process.

Any child process (init except) after the exit, not immediately disappear, but leave the data structure called a zombie process (Zombie), the parent process to wait for treatment. This is every child to go through the process at the end of the stage. If the child process after the exit (), the parent process does not have time to deal with, then use the ps command can see the status of the child process is "Z". If the parent process can be timely treatment, with a ps may be too late to see the zombie child process, but this does not mean that the child does not pass through a zombie state. If the parent process exits before the end of the child, the child init process will be taken over. init as a parent will be processed on the child zombie state.

Orphan process is no parent process, the process that orphans init process falls on the body, put the parent kernel process is set to orphans init, and init process cycle to wait () has withdrawn its child processes. Thus, when a miserable orphan process ended its life cycle time, so orphans do not have any harm.

Guess you like

Origin www.cnblogs.com/caohongchang/p/11618826.html