This code is just handling the SIGCHLD signal, but as you can see, the parent process should ignore this SIGCHLD signal according to the signal function. But in fact, the parent process will omit the signal function, and handling the child process using "wait". I wonder why the parent do not ignore the SIGCHLD signal?
A question about signal
1int main(argc,argv) {
2 int argc;
3 char *argv[] int i,ret_val,ret_code;
4 if(argc>1)
5 signal(SIGCLD,SIG_IGN);
6 for(i=0;i<10;i++)
7 if(fork()==0) {
8 printf("child proc %x\n",getpid());
9 exit(i);
10 }
11 ret_val=wait(&ret_code);
12 }
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.