What is the ignore sigchld signal seen in many source codes?

Source: Internet
Author: User
The role of ignore sigchld signal-preventing the generation of zombie Processes

Signal (sigchld, sig_igr); // ignores sigchld signals, which is commonly used as a technique for concurrent server performance.
// Because the concurrent server often fork many sub-processes and needs
// The server process cleans up resources through wait. If you set the signal processing method
// Ignore, so that the kernel can forward the zombie sub-process to the INIT process for processing, saving
// A large number of zombie processes occupy system resources. (Linux only)

Code: select all
Some code ();
PID = fork (); // generate a sub-process
If (PID <0) // error check.
Handle_err ();
If (pid = 0)
Exit (execl (...); // child process.
Else
If (wait (& RET) <0)
Perror ("wait"); // parent process

// Here wait will get the no such process error,
// After the sub-process is terminated, the kernel sends the sigchld to the parent process
// Signal, but the above signal has been set to ignore, essentially from
// Init to receive the processing of this sub-process.

In addition, the child process inherits the signal processing method of the parent 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.