Skip to content

Instantly share code, notes, and snippets.

@sinkovsky
Created May 12, 2011 11:33
Show Gist options
  • Save sinkovsky/968346 to your computer and use it in GitHub Desktop.
Save sinkovsky/968346 to your computer and use it in GitHub Desktop.
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