Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

^CSIGINT handler "my_handler" not defined. Sigtrap is not able to find handler function.

by girijaj (Initiate)
on Sep 17, 2014 at 06:36 UTC ( [id://1100887]=perlquestion: print w/replies, xml ) Need Help??

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

Hi all, Anyone could explain why my sigtrap is not able to see handler function? I am getting "^CSIGINT handler "my_handler" not defined." error.
use sigtrap 'handler' => \&my_handler, 'normal-signals';
and I have declared my_handler as:
sub my_handler { die "Caught signal $! \n"; }
Please help me I am not getting it what to do. thanks --girija
  • Comment on ^CSIGINT handler "my_handler" not defined. Sigtrap is not able to find handler function.
  • Select or Download Code

Replies are listed 'Best First'.
Re: ^CSIGINT handler "my_handler" not defined. Sigtrap is not able to find handler function.
by Corion (Patriarch) on Sep 17, 2014 at 06:54 UTC

    Is that a typo? You use my_handler and my_hanlder.

    use sigtrap 'handler' => \&my_handler, 'normal-signals'; sub my_hanlder { die "Caught signal $! \n"; }
      Thanks for the response. yes it was typo, i fixed it. I think its a scope of my program. Somehow I have to make this handler function visible to sigtrap. But I am not getting it how to do that.
Re: ^CSIGINT handler "my_handler" not defined. Sigtrap is not able to find handler function.
by jellisii2 (Hermit) on Sep 17, 2014 at 11:52 UTC
Re: ^CSIGINT handler "my_handler" not defined. Sigtrap is not able to find handler function.
by Mr. Muskrat (Canon) on Sep 18, 2014 at 17:49 UTC

    You need to provide more context if you want help but reduce it down to a minimal example that still does not work. Here's my minimal yet working example:

    #!/bin/env perl use strict; use warnings; use sigtrap 'handler' => \&my_handler, 'normal-signals'; while ( 1 ) { print "running...\n"; sleep 30; } sub my_handler { die "Caught signal $!\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1100887]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-25 09:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found