C Program To Allow The Parent Process To Wait For A Specific Child Process Termination
C program to allow the parent process to wait for a specific child process termination. Source Code: #include<stdio.h> #include<stdlib.h> #include<time.h> #include<unistd.h> void main() { int pid1,pid2,status; pid1=fork(); if(pid1==0) { sleep(5); printf("Hello i am child1\n"); } else { pid2=fork(); if(pid2==0) { sleep(10); printf("\nChild 2"); } else { waitpid(pid1,&status,0); printf("Parent process started"); } } }
Tags:
OS Related C progeams
0 comments