Question: Please answer this question Use the picture as a example. Write a programed name ch.c which should run five processes altogether. These are the requirements:

Please answer this question

Use the picture as a example.

Write a programed name ch.c which should run five processes altogether.

These are the requirements: a) At most three fork() function calls are allowed to appear in your .c> code. b) No for() loops, no do while loops, etc. c) Compile into an executable file called and run it on your Ubuntu system in VirtualBox. Then use top to show the five processes using a snapshot of your terminal window. gcc -o five five.c d) You have to use sleep() function to give enough time to take a snapshot before some or all of the processes finish and exit quickly.

#include #include #include int mainC pidt pid; /* fork a child process*/ pid = fork(); if (pid < 0)error occurred* fprintf(stderr, "Fork Failed" return 1; else if (pid 0) { /* child process */ execlpC"/bin/ls","ls", NULL); else /* parent process* /* parent will wait for the child to complete* wait CNULL); printfC"Child Complete"; return 0

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!