Advertisement
Guest User

net

a guest
Jul 28th, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<errno.h>
  4. #include<unistd.h>
  5. #include<sys/wait.h>
  6.  
  7. int main(void)
  8. {
  9. pid_t pid;
  10. pid=fork();
  11. if(pid<0)
  12. {
  13. perror("ERROR");
  14. exit(1);
  15. }
  16. else if(pid==0)
  17. {
  18. printf("This is the child proces\n");
  19. printf("My pid is:%d\n",getpid());
  20. printf("My parent id is:%d\n",getppid());
  21. exit(1);
  22. }
  23. else
  24. {
  25. printf("This is the parent process\n");
  26. printf("my pid is:%d\n",getpid());
  27. printf("my child's id:%d\n",pid);
  28. exit(1);
  29. }
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement