Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int childPid;
  6.  
  7. if ((childPid = fork()) == -1)
  8. {
  9. fprint(stderr, "can't fork\n");
  10. exit(1);
  11. }
  12. else if (childPid == 0)
  13. {
  14. fprintf(stdout, "child: child pid = %d, parent pid = %d\n",
  15. getpid(), getppid());
  16. exit(0);
  17. }
  18. else
  19. {
  20. fprintf(stdout, "parent: child pid = %d, parent pid = %d\n",
  21. childPid, getpid());
  22. exit(0);
  23.  
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement