Advertisement
Guest User

Untitled

a guest
Sep 18th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <unistd.h>
  2. #include <stdio.h>
  3.  
  4.  
  5. int main(int argc,char* argv[]){
  6. if(argc == 2){pid_t forkRE;forkRE = fork();
  7. if(forkRE==0){
  8. printf("Child's Process ID : %d \n",getpid());
  9. printf("Child's parent ID : %d \n",getppid());
  10. printf("Child's process group ID : %d \n\n",getpgrp());
  11. //execv("/bin/cat",argv);
  12. execl("/bin/cat","/bin/cat",argv[1],NULL);
  13. }else{
  14. wait(NULL);
  15. printf("Parent's Process ID : %d \n",getpid());
  16. printf("Parent's Parent ID : %d \n",getppid());
  17. printf("Parent's Process Group ID : %d \n\n",getpgrp());
  18. }
  19. }
  20. else
  21. printf("Error!!! \nTry again :) \n");
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement