Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include #include #include #include #include int main ( ) { pid _ t p; char input [ 1 0 0 ] ; while ( 1
#include
#include
#include
#include
#include
int main
pidt p;
char input;
while
printfEnter a command or 'Exit' to quit: ;
fgetsinput sizeofinput stdin;
Remove the newline character from the input
inputstrcspninput
;
if strcmpinput "Exit"
printfExiting
;
break;
p fork;
if p
perrorFork error";
exit;
if p Child process
char arg; Maximum of arguments
int i ;
char token strtokinput;
while token NULL
argi token;
token strtokNULL;
argi NULL; Nullterminate the argument list
Execute the command
if execvparg arg
perrorExec error";
exit;
else
Parent process
int status;
wait&status;
if WIFEXITEDstatus
printfChild process exited with status d
WEXITSTATUSstatus;
else
perrorWait error";
exit;
how can we use four exec functions in above program
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started