본문 바로가기
카테고리 없음

unix 명령어 - fork

by 책읽는구리 2011. 2. 24.
반응형
    

     3  int main(void)
     4  {
     5          switch(fork()) {
     6          case -1:                              // fork 실패
     7                  perror("fork");
     8                  exit(1);
     9          case 0:                               // child process
    10                  sleep(3);
    11                  system("banner CHILD");
    12                  system("ps -l");
    13                  exit(0);
    14          default :                              //부모가 수행
   
15                  sleep(10);
    16                  system("banner PARENT");
    17                  system("ps -l");
    18                  break;
    19          }
    20          return 0;
    21  }




>> 좀비 프로세스 발견하는 법

ps -el | awk '$2=="Z" { print $5 }'



>> ps

STATE OF THE PROCESS

S : Sleeping
W : Wating
R : Running
I : Intermidiate
Z : Terminated
T : Stopped



                                                                                 










반응형

댓글