Link Search Menu Expand Document

Background processes

So far, your shell waits for each program to finish before starting the next one. Many shells allow you run a command in the background by putting an & at the end of the command line. After the background program is started, the shell allows you to start more processes without waiting for the background process to finish.

Modify your shell so that it runs commands that end in an & in the background. Once you’ve implemented this feature, you should be able to run programs in the background with a command such as /bin/ls &.

You should also add a new built-in command wait, which waits until all background jobs have terminated before returning to the prompt.

You can assume that there will always be spaces around the & character. You can assume that, if there is a & character, it will be the last token on that line.