Question: create a Makefile for the following codes forkchildren1.c #include #include #include #include int main() { for(int i=0;i <5;i++) { if(fork() == 0) { for(int j=1;j

create a Makefile for the following codes

forkchildren1.c

#include #include #include #include int main() { for(int i=0;i<5;i++) { if(fork() == 0) { for(int j=1;j<=6;j++) { printf("I am child %d and this is my %d message ",getpid(),j); sleep(3); } exit(0); } else { pid_t cpid; cpid = wait(NULL); printf("Exited Child pid = %d ", cpid); } } }

forkchildren2.c

#include #include #include #include void main() { int n1 = fork(); int n2 = fork(); if (n1 == 0 && n2 > 0) //checking if child1 { system("ls -l"); exit(0); } else { pid_t cpid; cpid = wait(NULL); } if (n1 > 0 && n2 == 0) //checking if child2 { system("cat forkchildren.c"); exit(0); } else { pid_t cpid; cpid = wait(NULL); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!