Created
May 12, 2011 11:33
-
-
Save sinkovsky/968346 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Foo; | |
## моя статистика | |
our $stats = {}; | |
sub new { | |
return bless {}, shift; | |
} | |
$SIG{INT} = sub { | |
print "Module INT handler $$\n"; | |
exit; | |
}; | |
sub DESTROY { | |
# тут я думаю дампить статистику накопленную | |
print "In destroy $$ \n"; | |
} | |
sub END { | |
# или тут | |
print "In end $$ \n"; | |
} | |
1; | |
#!perl | |
use warnings; | |
use strict; | |
use Data::Dumper; | |
use Foo; | |
local $SIG{INT} = sub { | |
## here i plan to kill my forked children | |
print "In script INT $$ n\n"; | |
}; | |
## это мой супер обьект useragent который будет собирать статистику | |
my $f = Foo->new(); | |
my $pid = fork; | |
if ($pid ) { | |
print "Parent\n"; | |
} else { | |
delete $SIG{INT}; | |
} | |
sleep 5; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment