hisycg@gmail.com has asked for the wisdom of the Perl Monks concerning the following question:
then I have a test script to test it. test_Mypackage.plpackage Mypackage; use Moose; use Exporter qw(import); use sigtrap 'handler' => \&signal_handler_kill, 'INT', 'ABRT', 'QUIT', + 'TERM'; has status => ( isa => 'Str', is => 'rw' ); sub signal_handler_kill{ my $self_term=shift; my $self=shift; $self->status("killed"); $self->end; } sub end{ #do some clean up $self=shift; print $self->status."\n"; } 1;
I run the test script and kill it, but it returnsuse Mypackage; my $obj = Mypackage->new({status=>"start"}); sleep 20;
Can't call method "status" on an undefined value at Mypackage.pm line 10.
It seems the object is already destroyed beofre the signal caught, any idea? Thanks //Aaron
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Any one know how to use sigtrap with moose?
by Corion (Patriarch) on Jul 24, 2012 at 09:59 UTC | |
by Anonymous Monk on Jul 24, 2012 at 10:38 UTC | |
|
Re: Any one know how to use sigtrap with moose?
by tobyink (Canon) on Jul 24, 2012 at 10:20 UTC | |
by hisycg@gmail.com (Initiate) on Jul 24, 2012 at 11:19 UTC | |
by Corion (Patriarch) on Jul 24, 2012 at 11:35 UTC | |
by tobyink (Canon) on Jul 24, 2012 at 11:35 UTC | |
by Corion (Patriarch) on Jul 24, 2012 at 11:47 UTC | |
by tobyink (Canon) on Jul 24, 2012 at 13:49 UTC | |
by hisycg@gmail.com (Initiate) on Jul 24, 2012 at 12:23 UTC |