sub handler { local($sig) = @_; print "Caught SIG$sig\n"; exit(0); } $SIG{'INT'} = 'handler'; print "Hit CRTL-C to see if it is trapped\n"; while($_ = ) { print $_; }