[Israel.pm] DB_File + signals + modules
Yosef Meller
mellerf at netvision.net.il
Tue Aug 30 02:34:08 PDT 2005
Itamar Elem wrote:
> hi
>
> I have application which have main + most of the code reside in module
> and use MLDBM(DB_File,DATA::Dumper) to store/retrieve its data
> I want to recover from the situation that someone do CLRL+C or something like that
> because its left the DB_File in undefined state(the index and data is out of sync)
> I never used signal before sow I need some info about it
>
> 1. where to initiate the %SIG vector main/module or both?
You can do that anywhere, but if you only need it for a specific time,
you can localize it to a certain block:
if ($db_could_bork) {
local %SIG;
$SIG{INT} = sub { warn 'i\'m busy, come back later' };
do_risky_stuff();
}
See also perldoc perlvar (the part about %SIG) and perldoc perlipc.
> 2. what are necessary actions in the signal handler sub routines except to save the db to disk
> 3. if I connect to db via "$db=tie %h,"MLDBM",....";
>
> is the following are equivalent:
>
> a. $db->sync
> b. untie %h
> undef $db
>
> thanks itamar
>
>
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl
>
--
Keep on rocking in a free world!
More information about the Perl
mailing list