Path-Class-File-Lockable

 view release on metacpan or  search on metacpan

lib/Path/Class/File/Lockable.pm  view on Meta::CPAN

=cut

sub lock {
    my $self = shift;
    my $owner;
    if ( $^O eq 'MSWin32' ) {
        require Win32;
        $owner = Win32::LoginName();
    }
    else {
        $owner = shift || getlogin() || ( getpwuid($<) )[0] || 'anonymous';
    }

    # we have to lock our lock file first, to avoid
    # NFS and race condition badness.
    # so obtain a lock on our lock file, write our lock
    # then release the lock on our lock file.
    # we can't use File::NFSLock all by itself since it is
    # not persistent across processes.
    my $lock = File::NFSLock->new(
        {   file               => $self->lock_file,



( run in 0.265 second using v1.01-cache-2.11-cpan-8d75d55dd25 )