Advertisement
Guest User

Untitled

a guest
May 20th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <sys/wait.h>
  5.  
  6. int main ()
  7. {
  8.     pid_t pid;
  9.     printf("Moj PID : %d\n",getpid());
  10.     switch(pid = fork()){
  11.     case 0:{
  12.         printf("Jestem procesem potomnym (PID: ) - %d\n", getpid());
  13.         switch(pid = fork()){
  14.         case 0:
  15.             printf("Jestem procesem potomnym potomnym (PID: ) - %d\n", getpid());
  16.         default:
  17.             printf("Jestem procesem potomnym macierzystym (PID: ) - %d\n", getpid());
  18.         }
  19.     }
  20.     default:
  21.         printf("Jestem procesem macierzystym (PID: ) - %d\n", getpid());
  22.         return 0;
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement