Home‎ > ‎CIS 98‎ > ‎

Lab 12: Improved Input

In this lab you'll update the game from the last lab to handle signals.  


Shell scripts that perform important tasks often have to clean up before they exit. When a user signals that the script should end abruptly by hitting Ctrl-C on the keyboard the script must exit gracefully. In this lab you'll update your game script from last week to handle the Ctrl-C and Ctrl-Z keys. 

Disable Sleep

The game script takes input. Scripts that take input cannot be put into the background. Update your game script to disable the Ctrl-Z key using the stty program. Be sure to re-enable the Ctrl-Z key when the script exits! 

Exit Gracefully 

In the first part of the assignment your script disabled the Ctrl-Z key. If your script exits without re-enabling it because the user hits Ctrl-C then you won't be able to put anything in the background again. This is an example of leaving a mess for the user. Update your script to handle Ctrl-C so that if the user requests an immediate exit the Ctrl-Z key is re-enabled before your script exits. 

Turn In

Place the updated game script in your ~/lab12 folder
  1. ~/lab12/game


  • 10 points for the first part
  • 10 points for the second part