Thorium

 view release on metacpan or  search on metacpan

lib/Thorium/Utils.pm  view on Meta::CPAN

    die("Caught $sig_name, aborting\n");
}

local $SIG{'INT'}  = \&_sig_handler;
local $SIG{'TERM'} = \&_sig_handler;

sub block_new_invocations {
    my ($lock_file) = @_;

    unless ($lock_file) {
        my $username = getlogin || getpwuid($<) || 'unknown';
        my $s = $FindBin::Script;

        # clean up the filename so it's easier to read and Unix-safe
        $s =~ s/[.\-]/_/g;
        $s =~ s/[\{\[\(\<>)\]\}~\|\/]/_/g;
        $s =~ s/[\p{Zs}\t]+/_/g;
        $s =~ s/\&+/_and_/g;
        $s =~ s/[^\p{Alphabetic}\p{Nd}\-\.\+_]//g;

        $lock_file = sprintf('/tmp/thorium_utils_lock_file_%s_%s.lock', $username, $s);



( run in 0.340 second using v1.01-cache-2.11-cpan-454fe037f31 )