Guest User

Untitled

a guest
Apr 12th, 2010
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <sys/types.h>
  4. int main()
  5. {
  6.   int i;
  7.   fork();
  8.   fork();
  9.   for(i=0;i<10;i++) {
  10.     printf("pid: %d, %d\n", getpid(), i);
  11.     fflush(NULL);
  12.     sleep(1);
  13.   }
  14.   wait();
  15.   fork();
  16.   fork();
  17.   for(i=0;i<10;i++) {
  18.     printf("2 pid: %d, %d\n", getpid(), i);
  19.     fflush(NULL);
  20.     sleep(1);
  21.   }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment