Unix/linux Zombie Process

Source: Internet
Author: User
Tags signal handler

1. the generation of zombie processes :

When a process calls the Exit command to end its own life, it is not actually destroyed, but rather leaves behind a data structure called the "zombie process". At this point, it has abandoned almost all memory space, no executable code, and cannot be dispatched, just keep a location in the process list (its kernel stack resides in memory), record the exit status of the process and other useful information for other processes to collect. The status of the process becomes Exit_zombie, and the SIGCHLD signal is sent to the parent process, and Linux defaults to ignoring the signal, and the parent process can display the signal to install it, call the wait or waitpid function in the signal handler function and wait for the child process to end and clear it completely. If the parent process does not do so, the child process becomes a zombie process. But after the parent process dies, all its processes are passed on to the Init process, and the INIT process periodically calls the wait system call to clear its zombie child.

2. hazards of the zombie process :

A few zombie processes do not have any impact on the performance of the system, but because the Linux system has a limited number of processes to run, if the resulting zombie process is too large, it will take up the available process numbers, which can cause new processes to fail to build.

3. avoidance of zombie processes :

(1) When the process is created call two fork, and the immediate child process to exit, so that the grandson process becomes an orphan

Process, the INIT process will be responsible for cleaning up the orphan process.

(2) Under Linux, you can simply set the operation of the SIGCHLD signal to sig_ign so that the kernel ends at the child process

The zombie process is not generated. In SVR4, if you call signal or Sigset to set the SIGCHLD configuration to

Ignored, and no zombie process is generated.

(3) Call wait or waitpid to wait for the child process to end, collect the information left by the zombie process, and make the zombie process

The bottom disappears.

Note: You cannot use kill to pick up a SIGKILL signal such as kill the zombie process like killing normal process, because the zombie process is already dead process, it can no longer receive any signal.

Unix/linux Zombie Process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.