A question about signal

alien2006.happy 0 Tallied Votes 151 Views Share

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?

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 }