Question: SO far Tests Failed: Test running command with & , Test history , Test invalid command, Test UNIX pipe, Test redirection of input , Test
SO far Tests Failed: Test running command with & Test history Test invalid command, Test UNIX pipe, Test redirection of input Test redirection of out
prog.cpp file
#include
#include
#include
#include
#include
#include
#include
#define MAXLINE
int mainvoid
char argsMAXLINE;
int shouldrun ;
char historyMAXLINE;
while shouldrun
printfosh;
fflushstdout;
char inputMAXLINE;
fgetsinput MAXLINE, stdin;
Check for history command
if strcmpinput
if strlenhistory
printfNo commands in history
;
continue;
else
strcpyinput history; Use the last command
printfs
history; Echo the history command
else
strcpyhistory input; Save command to history
Tokenize the input
char token strtokinput
;
int i ;
int background ;
while token NULL
argsi token;
token strtokNULL
;
argsi NULL;
if i && strcmpargsi &
background ;
argsi NULL;
Exit command
if strcmpargs "exit"
shouldrun ;
continue;
pidt pid fork;
if pid
perrorFork failed";
exit;
else if pid
Child process
execvpargs args;
perrorexec failed";
exit;
else
Parent process
if background
waitNULL;
return ;
Include commands got deleted so i included photo
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
