Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <stdio.h>
- int main(int argc,char* argv[]){
- if(argc == 2){pid_t forkRE;forkRE = fork();
- if(forkRE==0){
- printf("Child's Process ID : %d \n",getpid());
- printf("Child's parent ID : %d \n",getppid());
- printf("Child's process group ID : %d \n\n",getpgrp());
- //execv("/bin/cat",argv);
- execl("/bin/cat","/bin/cat",argv[1],NULL);
- }else{
- wait(NULL);
- printf("Parent's Process ID : %d \n",getpid());
- printf("Parent's Parent ID : %d \n",getppid());
- printf("Parent's Process Group ID : %d \n\n",getpgrp());
- }
- }
- else
- printf("Error!!! \nTry again :) \n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement