os final project
TRANSCRIPT
C-ShellMark and Turner
Patterns
• Reactor
• Singleton
• Interpreter
• Factory
• Builder
Shell Reactor
• main function
• while loop, terminates when user enters “exit”
• Sends user input command to parser
ShellParser• Splits up each word in the
passed string based off of “ “ character.
• Pushes into a vector of strings.
• Also controls things such whether process will run in background, piping, output.
• Creates a new job from command.
• T
Job
• Factory
• makeJob() makes a new process from the commands
• launch() launches the process in job once they are made
• Job sets up piping for multiple process
Process
• With each process, a new process object is created.
• The process is then forked and exec’ed
• Output is printed to terminal
Shell
• Singleton Pattern- only one instance
• Holds a lot of the variables we need to keep global such as our command vector and terminal process id
• Mostly consists of accessor methods
Shell Commands• ls - lists all files in the directory
• cd - changes directory
• dirs - outputs current directory path
• exec - execs a process, then quits
• wait - waits for a process to finish based off of its pid
• help - displays a small help menu with valid commands
Some Challenges
• Piping- it took some time to figure out job management that allowed us to pipe.
• Parsing Special Characters- size_t overflow due to npos being values as “-1”
• Testing- Finding good use cases to test each feature as it was implemented.
Demonstration