unix2016 assignment6 note
#Requirements
We will write a tiny shell (tsh) command processor like sh, bash, or csh for single line commands. Your shell’s main loop will display a prompt, read a line of input, and fork a child process to perform the indicated command.
Required capabilities:
Ordinary commands, consisting of an executable program name and an optional list of arguments, run in a separate process.
Two built-in commands: cd and pwd
Background processing, when the last token in the command line is “&”.
#Implementation
get user input
parse oneline cmd , create command argv &
if cmd is build-in cmd, call corresponding system call
if not, create a child process, and execvp the cmd
1
The exec family of functions replaces the current process image with a new process image.
if it is not a background process, use waitpid for childprocess