Step 7 - Challenge: Handling Signals
Step 7 - Challenge: Handling Signals
Build Your Own Shell (Python Edition)
Step 1 - Create The Simplest Possible Command Line Shell
Step 1 - Create The Simplest Possible Command Line Shell
Step 2 - Challenge: Handle Multiple Commands
Step 2 - Challenge: Handle Multiple Commands
Step 3 - Non Existent Commands
Step 3 - Non Existent Commands
Step 4 - External Commands With Arguments
Step 4 - External Commands With Arguments
Step 7 - Handling Signals
Step 7 - Handling Signals
Conclusion
Conclusion
In this step your goal is to handle signals that would interrupt the shell. For example CTRL-C. When a user enters CTRL-C to quit a program we don’t want it to terminate the shell as well.
That said we do still want to be able to quit commands we’ve run in our shell with CTRL-C, so you will need to ensure the signal handler is restored for external commands.
Here’s what that looks like:
% ccsh
ccsh> ^C
ccsh> cat
^Cccsh> exit
ccsh %In this example we can see that CTRL-C (rendered as ^C) does not terminate the shell, but does terminate the external command cat.