Create 5 child processes for a process. The processes should be executing in
parallel. The parent process should wait till all the child processes are terminated.
Solution :-
#include<stdio.h> #include<sys/types.h> #include<unistd.h> int main() { int i; for(i=0;i<5;i++) { if(fork()==0) { printf("\n"); printf("I am Child No.:%d\n",i+1); printf("My pid is:%d\n",getpid()); printf("My ppid is:%d\n",getppid()); printf("My uid is:%d\n",getuid()); printf("My gid is:%d\n",getgid()); exit(0); } } printf("\nI am father...!!!\n"); printf("My pid is:%d\n",getpid()); printf("My uid is:%d\n",getuid()); printf("My gid is:%d\n",getgid()); return 0; }
0 comments:
Post a Comment