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
Ubic::Lockf(3) User Contributed Perl Documentation Ubic::Lockf(3)

Ubic::Lockf - file locker with an automatic out-of-scope unlocking mechanism

version 1.58

    use Ubic::Lockf;
    $lock = lockf($filehandle);
    $lock = lockf($filename);
    undef $lock; # unlocks either

"lockf" is a perlfunc "flock" wrapper. The lock is autotamically released as soon as the associated object is no longer referenced.

lockf($file, $options)
Create an Lockf instance. Always save the result in some variable(s), otherwise the lock will be released immediately.

The lock is automatically released when all the references to the Lockf object are lost. The lockf mandatory parameter can be either a string representing a filename or a reference to an already opened filehandle. The second optional parameter is a hash of boolean options. Supported options are:

shared
OFF by default. Tells to achieve a shared lock. If not set, an exclusive lock is requested.
blocking
ON by default. If unset, a non-blocking mode of flock is used. If this flock fails because the lock is already held by some other process, "undef" is returned. If the failure reason is somewhat different, permissions problems or the absence of a target file directory for example, an exception is raised.
timeout
Undef by default. If set, specifies the wait timeout for acquiring the blocking lock. The value of 0 is equivalent to blocking => 0 option.
mode
Undef by default. If set, a chmod with the specified mode is performed on a newly created file. Ignored when filehandle is passed instead of a filename.
name()
Gives the name of the file, as it was when the lock was taken.
dissolve()
Destroy lock object without unlocking.

This is useful in forking code, if you have one lock object in several processes and want to close locked fh in one process without unlocking in the other.

Vyacheslav Matyukhin <mmcleric@yandex-team.ru>

This software is copyright (c) 2015 by Yandex LLC.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2015-01-27 perl v5.32.1

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

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