Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Signal Handling

by lidden (Curate)
on May 13, 2012 at 08:59 UTC ( #970257=note: print w/replies, xml ) Need Help??

in reply to Signal Handling

You can set set the handler to a subroutine.

$SIG{INT} = sub { <code goes here> };

See perldoc perlipc.

Replies are listed 'Best First'.
Re^2: Signal Handling
by anshumangoyal (Scribe) on May 21, 2012 at 06:35 UTC
    Is there any other work out. Actually I want to write a Interrupt Subroutine which should take Parameters. This way it's not going to work.
      Well, often what you want to do is something like:

      $SIG{INT} = sub { our $sigint_gotten = 1;}; # Later in the code if(our $sigint_gotten){ our $sigint_gotten = 0; deal_with_it($arg1, $arg2, ...); }

      I can't imagine how you would send a SIGINT with a parameter but you can do whatever you want in the subroutine you assign to SIGINT. Just remember that you want to return control to the system ASAP once you're in the handler. Maybe something like this would work for you...

      $SIG{INT} = sub { my $obj = Whatever->new(); process_interrupt($obj) };

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://970257]
[erix]: how does one find out how to install a program like cvsgrep
[erix]: I mean, I suppose it's just the one file so I can download that
[erix]: Makefile.PL should tell me, probably

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2017-06-22 16:44 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (524 votes). Check out past polls.