Advertisement
Pagoniusz

Untitled

Mar 26th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. #include <unistd.h>
  2. #include <sys/wait.h>
  3. #include <stdio.h>
  4. int main()
  5. {
  6.   int pid, pid2, pid3;
  7.   pid = fork();
  8.  
  9.   if( pid  == 0 )//potomny 1
  10.     {          
  11.       execl( "d1","", NULL );
  12.       sleep(1000000);
  13.     }
  14.   else
  15.     {
  16.       pid2=fork();
  17.       if(pid2==0)
  18.     {//potomny2  
  19.       execl( "d2","", NULL );
  20.       sleep(1000000);    
  21.     }
  22.       else
  23.     {
  24.       pid3=fork();
  25.       if(pid3==0)//potomny3
  26.         {
  27.           execl( "d3","", NULL );
  28.           sleep(100000);
  29.         }
  30.       else
  31.         {
  32.           waitpid(pid, NULL, 0);
  33.           waitpid(pid2, NULL, 0);
  34.           waitpid(pid3,NULL, 0);
  35.         }
  36.     }
  37.     }
  38.   //printf("%d %d %d", pid, pid2, pid3);
  39.   // waitpid(pid, NULL, 0);
  40.   //waitpid(pid2, NULL, 0);
  41.   // waitpid(pid3,NULL, 0);
  42. }
  43.  
  44.  
  45. https://www.drivehq.com/folder/p12389137.aspx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement