Advertisement
Guest User

Untitled

a guest
May 20th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 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 -1:
  12.         printf("fork error\n");
  13.     case 0:
  14.         printf("%d\n", getpid());
  15.         printf("%d\n", getppid());
  16.         printf("%d\n", pid);
  17.         return 0;
  18.     default:
  19.     wait(0);
  20.     printf("zakonczono proces potomny:");
  21.         printf("%d\n", getpid());
  22.         printf("%d\n", getppid());
  23.         printf("%d\n", pid);  
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement