blib/lib/IPC/Lockfile.pm untested

filter: Statementstmt 0.0% 0 / 12 Conditioncond 0.0% 0 / 2 Subroutinesub 0.0% 0 / 3 totaltotal 0.0% 0 / 17 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 use strict;
2 use warnings;
3 package IPC::Lockfile;
4 $IPC::Lockfile::VERSION = '0.01';
5 # ABSTRACT: run only one instance of a program at a time using flock
6 use Fcntl qw(:flock);
7  
8 flock DATA, LOCK_EX|LOCK_NB or die "$0 is running!\n";;
9  
10  
11 1;
12  
13 =pod
14  
15 =encoding UTF-8
16  
17 =head1 NAME
18  
19 IPC::Lockfile - run only one instance of a program at a time using flock
20  
21 =head1 VERSION
22  
23 version 0.01
24  
25 =head1 SYNOPSIS
26  
27 Just import the module:
28  
29 #!/usr/bin/env perl
30 use IPC::Lockfile;
31  
32 ... # program code here
33  
34 No external lockfile is created, C<IPC::Lockfile> uses C<_DATA_> (See L<#THANKS>).
35  
36 =head1 DESCRIPTION
37  
38 C<IPC::Lockfile> is a module for use with Perl programs when you only want one
39 instance of the script to run at a time. It uses C<flock> and should work if
40 run on an OS that supports C<flock> (e.g. Linux, BSD, OSX and Windows).
41  
42 =head1 THANKS
43  
44 This module implements an elegant L<solution|http://perl.plover.com/yak/flock/samples/slide006.html> to lockfiles proposed by Mark Jason Dominus.
45  
46 =head1 SEE ALSO
47  
48 L<IPC::Pidfile> for a PID-based solution that relies on signals and has a race
49 condition (not recommended).
50  
51 =head1 AUTHOR
52  
53 David Farrell <dfarrell@cpan.org>
54  
55 =head1 COPYRIGHT AND LICENSE
56  
57 This software is Copyright (c) 2015 by David Farrell.
58  
59 This is free software, licensed under:
60  
61 The (two-clause) FreeBSD License
62  
63 =cut
64  
65 __DATA__