bourne shell "read" vs. hangup trap (1)

Paul Tarvydas tarvydas at utcsri.UUCP
Sun Nov 24 09:13:44 AEST 1985


On the two machines which I've tried this, a "hangup" trap does not
cause the (Bourne) shell's "read" command to abort.  Instead, the
shell script continues to execute and sucks up inordinate amounts of
cpu time.  What would be a more appropriate way to code up a "read"
from the keyboard, while maintaining the ability to die gracefully
when a hangup comes by?

The problem can be summarized with the following test script.  I would
have expected the script to terminate after updating "hangup.LOG" when
a hangup trap occurs - this does not appear to be the case.

#!/bin/sh
trap "date >>hangup.LOG; exit 1" 1 2 3 15
while true
do
        read junk
done

Paul Tarvydas
...!utcsri!tarvydas



More information about the Comp.unix.wizards mailing list