- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Perl Question
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2006 04:33 AM
08-07-2006 04:33 AM
How do I temporarily replace a signal handler inside a perl function and then restore the previous signal handler?
TIA,
Steve
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2006 04:39 AM
08-07-2006 04:39 AM
Solutionmy $Flag = 0;
sub my_local_handler
{
$SIG{INT} = \&my_local_handler;
++$Flag;
return(0);
} # my_local_handler
sub my_function
{
local $SIG{INT} = \&my_local_handler;
...
...
return(0);
} # my_function
The key is the "local" scope. When my_function falls out of scope then the signal handler for SIGINT reverts to its prior value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2006 04:41 AM
08-07-2006 04:41 AM
Re: Perl Question
Use a 'local' declaration for your handler. For instance:
sub mything {
local $SIG{INT} = \&myhandler;
...
}
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2006 05:02 AM
08-07-2006 05:02 AM
Re: Perl Question
A. Clay, why do you do this inside the signal handler?
sub my_local_handler
{
$SIG{INT} = \&my_local_handler;
++$Flag;
return(0);
} # my_local_handler
It looks like you are setting the signal handler to itself. Was this a typo?
Thanks,
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2006 05:11 AM
08-07-2006 05:11 AM
Re: Perl Question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2006 05:14 AM
08-07-2006 05:14 AM