Advertisement
Guest User

C linux

a guest
Apr 26th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4.  
  5. int main(void)
  6. {
  7.     int foo;
  8.  
  9.     printf("pid \t %d \n", getpid());
  10.     printf("ppid \t %d \n", geppid());
  11.  
  12.     foo = fork();
  13.     printf("foo = %d \n", foo);
  14.  
  15.     if(foo > 0) {
  16.         printf("Jestem procesem maciezystym! ID = %d \n", getpid());
  17.     }
  18.     else {
  19.         printf("Jestem potomkiem! ID = %d \n", getpid());
  20.     }
  21.  
  22.     if(foo == -1) {
  23.         printf("Blad! \n");
  24.     }
  25.  
  26.     return EXIT_SUCCESS;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement