Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6656211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:36:55+00:00 2026-05-26T01:36:55+00:00

Have the following in my module’s BEGIN section: use sigtrap qw(handler shutdown normal-signals); use

  • 0

Have the following in my module’s BEGIN section:

use sigtrap qw(handler shutdown normal-signals);
use sigtrap qw(die untrapped normal-signals stack-trace any error-signals);

But when sigtrap catches INT,etc.. what I get in my shutdown sub only contains the trap and not the object handle. No $self.

sub shutdown {
    my $sig = shift || 'Nothing';   
    print "Got signal: $sig\n";
    exit;
}

simply returns

Got signal: INT

My DESTROY get’s called right on time after this and has access to the object handle, but because I didn’t have access to the handle in my shutdown, I couldn’t store it and have no idea what the signal was.

I need to know what trap I got so my DESTROY method can log what caused the shutdown.

Perhaps sigtrap isn’t the best choice here. Opinions welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:36:56+00:00Added an answer on May 26, 2026 at 1:36 am

    I checked sigtrap, it’s not specifically an OO module, if you want to use it as one, you may need to use a closure instead of an object method.

    So you might define your class like so:

    package SigHandler;
    
    sub new { 
        my $class = shift;
        return bless { @_ }, $class;
    }
    
    sub on_signal_int { 
        my $self = shift;
        ...
    }
    
    sub get_handler { 
        my $self       = shift;
        my @other_args = shift;
        ...
        return sub { 
            my $sig = shift;
            if ( $sig == INT ) { 
                return $self->on_signal_int();
            }
        };
    }
    

    And then call it like so:

    use handler => SigHandler->new->get_handler, 'normal-signals';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following simple type: module Structures type Point2D<'T> (x : 'T, y
I have written a module similar to the following: module One class Two def
I have the following code in my Mojolicious application module. When I run this
I have the following code: class MyClass module MyModule class << self attr_accessor :first_name
I have the following Drools DSL sentence: [when]The field {field} in the module {module}
So I have the following function in my drupal module. I want to submit
I have the following code in my simple ubercart payment gateway module to redirect
I created a custom module for Orchard following this wonderful guide . I have
I have the following module public class LowerCaseRequest : IHttpModule { public void Init(HttpApplication
I have the following configuration: module A module B def foo puts foo end

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.