Question: prog.cpp #include #include #include #include #include #include #include using namespace std; #define MAX _ LINE 8 0 / / The maximum length command / *
prog.cpp
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define MAXLINE The maximum length command
@brief parse out the command and arguments from the input command separated by spaces
@param command
@param args
@return int
int parsecommandchar command char args
TODO: implement this function
TODO: Add additional functions if you need
@brief The main function of a simple UNIX Shell. You may add additional functions in this file for your implementation
@param argc The number of arguments
@param argv The array of arguments
@return The exit status of the program
int mainint argc, char argv
char commandMAXLINE; the command that was entered
char argsMAXLINE ; hold parsed out command line arguments
int shouldrun ; flag to determine when to exit program
TODO: Add additional variables for the implementation.
while shouldrun
printfosh;
fflushstdout;
Read the input command
fgetscommand MAXLINE, stdin;
Parse the input command
int numargs parsecommandcommand args;
TODO: Add your code for the implementation
After reading user input, the steps are:
fork a child process using fork
the child process will invoke execvp
parent will invoke wait unless command included &
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
