File: README

package info (click to toggle)
liblockfile-simple-perl 0.2.5-7
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 100 kB
  • ctags: 57
  • sloc: perl: 507; makefile: 35; ansic: 1
file content (80 lines) | stat: -rw-r--r-- 2,601 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
                        LockFile::Simple 0.2
              Copyright (c) 1998-1999, Raphael Manfredi

------------------------------------------------------------------------
    This program is free software; you can redistribute it and/or modify
    it under the terms of the Artistic License, a copy of which can be
    found with perl.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    Artistic License for more details.
------------------------------------------------------------------------

       *** This is alpha software -- use at your own risks ***

Name           DSLI  Description                                  Info
-----------    ----  -------------------------------------------- -----
LockFile::           Application-level locking facilities
::Simple       adpr  Simple file locking mechanism                RAM
::Lock::       ----  Lock handles created by LockFile::* schemes  RAM
::Manager      ----  Records locks created by LockFile::*         RAM

SYNOPSIS

	#
	# The simple way
	#

	use LockFile::Simple qw(lock unlock);

	lock("file") || die "Can't lock file\n";
	open(FILE, ">>file") || die "Can't append to file: $!\n";
	....
	close FILE;
	unlock("file");

	#
	# The more elaborated way
	#

	use LockFile::Simple;

	my $scheme = LockFile::Simple->make(
		-autoclean => 1,
		-format => "%f.lck");

	$scheme->lock($0, "/var/run/%F.%p") || die "already running";

	my $lock = $sheme->lock("file");
	open(FILE, ">>file") || die "Can't append to file: $!\n";
	....
	close FILE;
	$lock->release;

DESCRIPTION

The LockFile::Simple extension provides simple file locking, of
the advisory kind, i.e. it requires cooperation between applications
wishing to lock the same files.

It is meant to be used in quick-and-dirty scripts or more elaborated
programs that want a simple locking scheme, yet with a reasonable
level of configuration.

This code comes from the mailagent-3.0 package and retains most
of its configuration abilities.

I do not intend to leave this simple scheme as-is forever. The code is
designed to be extended to offer other locking schemes, such as
MTA locking--usually a combination of this simple scheme and flock().

Despite being flagged as simple and not bullet proof all over the
place, locking is good enough in practice for simple applications
wishing to protect against concurrent actions.

There is an embeded POD manual page in Simple.pm.

-- Raphael Manfredi <Raphael_Manfredi@pobox.com>