[ create a new paste ] login | about

Link: http://codepad.org/sgr1No1r    [ raw code | output | fork ]

C, pasted on Jun 22:
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
int count = 0;
void my_sig(int signo){
  int status =0;
  while( waitpid(-1 , &status , WNOHANG )  > 0){  
    if( (status & 0x7f) == 0){
       printf(" 정상종료 %d \n",(status>>8)&0xff );
    }else if( (status & 0xff00) == 0 ){
      printf("비정상종료 %d \n",(status>>8)&0xff );
    }
    printf("count = %d \n",++count); // 올바르게 죽는지 Check
  }
}

int main(void){
 int i;
 signal(SIGCHLD, my_sig);
 for(i=0;i<1000;i++)
 {
  if( fork() == 0){
    sleep(3);
    aboart();
    // exit(7)    // exit_code = 7;
  }  
 }
  while(1){
    printf(".\n");
    sleep(1);
 }  
}


Output:
1
2
In function `main':
undefined reference to `aboart'


Create a new paste based on this one


Comments: