neilwatson has asked for the wisdom of the Perl Monks concerning the following question:

I'm currently using Tie::Syslog to log any dies or errors as a result of incorrect user input. What about interrupts? If a user performs a ctrl-c is there a way I can catch and log that to stderr?

Neil Watson
watson-wilson.ca

Replies are listed 'Best First'.
Re: Logging interrupt signals
by davis (Vicar) on Sep 12, 2003 at 15:07 UTC

    You want to look at sh$ perldoc -q signal - this shows you how to add entries to the SIG hash - e.g.

    $SIG{INT} = sub { $Interrupted++; syswrite(STDERR, "ouch\n", 5); }

    cheers


    davis
    It's not easy to juggle a pregnant wife and a troubled child, but somehow I managed to fit in eight hours of TV a day.
Re: Logging interrupt signals
by broquaint (Abbot) on Sep 12, 2003 at 15:12 UTC
    Just point the INT signal handler at some code e.g
    $SIG{INT} = sub { warn @_ };
    See. the %SIG entry in perlvar for more information on setting up signal handlers.
    HTH

    _________
    broquaint