Foreground/background switching
Most shells allow for running processes to be toggled between running in the foreground versus in the background. You can optionally add two built-in commands to support this:
fg [pid]
Move the process with id
pid
to the foreground. The process should resume if it was paused. Ifpid
is not specified, then move the most recently launched process to the foreground.
bg [pid]
Resume a paused background process. If
pid
is not specified, then resume the most recently launched process.
You should keep a list of all existing processes (whether they are in the foreground or background) and their pids. Inside this list, you should also keep a struct termios
to store the terminal settings of each program.