Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <sys/types.h>
  3.  
  4. #define MAX 1000
  5.  
  6. void ChildProcess(void);
  7. void ParentProcess(void);
  8.  
  9. void main(void)
  10. {
  11. pid_t pid;
  12.  
  13. pid = fork();
  14. if (pid == 0)
  15. ChildProcess();
  16. else
  17. ParentProcess();
  18. }
  19.  
  20. void ChildProcess(void) {
  21. pid_t pid_ch = getpid();
  22.  
  23. int i = 1, k = 0;
  24.  
  25. printf(" *** Child (%d) process is done ***\n", pid_ch);
  26. }
  27.  
  28. void ParentProcess(void) {
  29. int i;
  30. pid_t pid_p = getpid();
  31.  
  32. print_f("*** Parent (%d) is done ***\n", pid_p);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement