Question: Implement a closh (Clone Shell) designed to run multiple copies of a program at once. Closh takes as input the name of the program to

Implement a closh (Clone Shell) designed to run multiple copies of a program at once.

Closh takes as input the name of the program to run, the number of copies (processes) of the program to run - an integer from 1 to 9 and whether the processes should execute concurrently or sequentially.

Closh executes the given program the specified number of times, then returns to the prompt once all processes have either completed or timed out. The shell should be written in C++. Use execlp() to create a new child process and have it execute a command and waitpid in the parent process to wait for the child process to finish in case sequential execution is selected.

Here is a simple example of using closh (bold is program output, italic is user input):

./closh

closh> ./hello.exe

count> 3

[p]arallel or [s]equential> p

hello world

hello world

hello world

closh>

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!