GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  PARANOID::LOCKFILE (3)

.ds Aq ’

NAME

Paranoid::Lockfile - Paranoid Lockfile support

CONTENTS

VERSION

$Id: Lockfile.pm,v 0.65 2011/12/08 07:53:07 acorliss Exp $

SYNOPSIS



  use Paranoid::Lockfile;

  $rv = plock($lockfile);
  $rv = punlock($lockfile);
  $rv = pcloseLockfile($lockfile);



DESCRIPTION

This modules provides a relatively safe locking mechanism across multiple processes. This does not work over NFS or across remote systems, this is only intended for use on a single system at a time, and only on those that support <B>flockB>.

<B>sysopenB> is used to avoid race conditions with multiple process attempting to create the same file simultaneously.

SUBROUTINES/METHODS

    plock



  $rv = plock($filename);



This function attempts to safely create or open the lockfile. It uses <B>sysopenB> with <B>O_CREAT | O_EXCLB> to avoid race conditions with other processes. Returns a true if successful.

Your can pass an optional second argument which would be a string of either ’write’ or ’shared’. The default is ’write’, which locks the file in exclusive write mode.

You can pass an optional third argument which would be the lockfile filesystem permissions if the file is created. The default is 0600.

<B>NOTE:B> This function will block until the advisory lock is granted.

    punlock



  $rv = punlock($filename);



This function removes any existing locks on the specified filename using <B>flockB>. If no previous lock existed or it was successful it returns true. This does not, however, close the open filehandle to the lockfile.

    pcloseLockfile



  $rv = pcloseLockfile($filename);



This function releases any existing locks and closes the open filehandle to the lockfile. Returns true if the file isn’t currently open or the operation succeeds.

DEPENDENCIES

o Fcntl
o Paranoid
o Paranoid::Debug

BUGS AND LIMITATIONS

AUTHOR

Arthur Corliss (corliss@digitalmages.com)

LICENSE AND COPYRIGHT

This software is licensed under the same terms as Perl, itself. Please see http://dev.perl.org/licenses/ for more information.

(c) 2005, Arthur Corliss (corliss@digitalmages.com)

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 PARANOID::LOCKFILE (3) 2011-12-08

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.