Skip to content

Instantly share code, notes, and snippets.

@nekokak
Created January 12, 2012 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nekokak/1599692 to your computer and use it in GitHub Desktop.
Save nekokak/1599692 to your computer and use it in GitHub Desktop.
#! perl
use strict;
use warnings;
use DBI;
use Sys::SigAction qw(set_sig_handler);
my $h = set_sig_handler(
'ALRM',
sub {
print "fire\n";
},
);
if ( fork ) {
sleep(1);
# $SIG{ALRM} = sub { print "fire\n"; };
alarm(3);
my $dbh = DBI->connect('dbi:SQLite:./hoge.db', '', '');
$dbh->do('select * from user');
wait;
} else {
open my $fh, './hoge.db';
flock($fh, 6);
sleep(10);
close $fh;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment