Question: Q4. Write a program in C/C++ that does the following a. Presents a user promptand reads a line from the terminal terminated by an end
Q4. Write a program in C/C++ that does the following a. Presents a user promptand reads a line from the terminal terminated by an end of line character Breaks the line into a series of strings ignoring white space (spaces and tabs) Considers the first string to be a command and the remainder to be the arguments for the commands b. c. d. If the command is 'exit' then your program stops e. If the command is 'run' then the second string is considered to be an executable file name, and the remaining strings are arguments to this executable file: Fork is used to create a new child process to execute the file Exec is used in the child process to replace the text segment with the code from the executable file and to pass the remaining parameters a. b. process ends and then retums to the f. Any other value of the first string should be ignored, and the prompt repeated. You will need to look up the fork and exec commands using man, and you will need to c. Your program waits until the child user prompt. decide which form of exec to use
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
