A question about signal

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
alien2006.happy alien2006.happy is offline Offline Oct 29th, 2009, 4:04 am |
0
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?
Quick reply to this message  
C Syntax
  1. 1int main(argc,argv) {
  2. 2 int argc;
  3. 3 char *argv[] int i,ret_val,ret_code;
  4. 4 if(argc>1)
  5. 5 signal(SIGCLD,SIG_IGN);
  6. 6 for(i=0;i<10;i++)
  7. 7 if(fork()==0) {
  8. 8 printf("child proc %x\n",getpid());
  9. 9 exit(i);
  10. 10 }
  11. 11 ret_val=wait(&ret_code);
  12. 12 }

Message:


Similar Threads
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC