DarkSpect

scomp1.2

Feb 28th, 2012
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.34 KB | None | 0 0
  1. int main(){
  2.     pid_t p,a;
  3.     int i;
  4.         p=fork();
  5.         a=fork()
  6.         if(a==0)
  7.             break;
  8.         if(a==0){
  9.             printf("Eu sou o 2º filho %d", getpid());
  10.             exit(2);
  11.         }else
  12.             if(a>0 && p==0){
  13.                 printf(Eu sou o 1º filho %d",getpid());
  14.                 exit(1);
  15.         }else
  16.             if(p>0){
  17.                 wait();
  18.                 printf("Eu sou o pai %d", getpid());
  19.         }
  20.     return 0;
  21.        
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment