Question: / * XXX DO NOT MODIFY THIS FILE XXX * / #define _ POSIX _ C _ SOURCE 2 0 0 8 0 9 #include
XXX DO NOT MODIFY THIS FILE XXX
#define POSIXCSOURCE
#include
#include
#include
#include
#include
#include
#include
#include
#include "exit.h
#include "params.h
#include "parser.h
#include "runner.h
#include "signal.h
#include "utilgprintfh
#include "wait.h
Main bigshell loop
int
mainint argc, char argv
struct commandlist cl ;
Program initialization routines
if parserinit goto err;
TODO Enable this line once you've implemented the function
if signalinit goto err;
Main Event Loop: REPL Read Evaluate Print Loop
for ;;
prompt:
Check on backround jobs
if waitonbgjobs goto err;
Read input and parse it into a list of commands
TODO Enable this line once you've implemented the function
if signalenableinterruptSIGINT goto err;
int res commandlistparse&cl stdin;
TODO Enable this line once you've implemented the function
if signalignoreSIGINT goto err;
if res System library errors
switch errno Handle specific errors
case EINTR:
clearerrstdin;
errno ;
fputc
stderr;
goto prompt;
default:
goto err; Unrecoverable errors
else if res Parser syntax errors
fprintfstderr "Syntax error: s
commandliststrerrorres;
errno ;
goto prompt;
else if res No commands parsed
if feofstdin bigshellexit; Exit on eof
goto prompt; Blank line
else
gprintfParsed command list to execute:";
#ifndef NDEBUG
commandlistprintcl stderr;
fputc
stderr;
#endif
gprintfexecuting command list with zu commands", clcommandcount;
Execute commands
runcommandlistcl;
Cleanup
commandlistfreecl;
freecl;
cl ;
err:
if cl commandlistfreecl;
freecl;
params.status ;
warn;
bigshellexit;
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
