 | | This program uses alarm to set a ten-second timeout, and then prompts for the string. If the user enters a string, the read (fgets) returns, the alarm is turned off, the flag variable is still 0, and the program uses the string the user entered. However, if the user doesn't type anything, the alarm goes off, resulting in a call to handler, which sets flag to 1. The signal handler returns, the value of flag results in copying the default string value into buf, and the program continues. | |
|