First off, i'd highly suggest using flock() if at all possible.

The big limitation here is that File::lockf is a Perl binding to the SYSV lockf(3) call. Since lockf(3) will never return a 9, my guess is that the Perl binding (File::lockf) is returning the value that errno is set to.

Now the next hurdle; how do you figure out what an errno value corresponds to? ... with the strerror(3) (POSIX/SYSV/BSD/ISO 9899, etc) call. OOOoooh loook, it conforms to POSIX! =) That means that we're in luck (*this* time), since Perl has a fairly complete POSIX module.

The short answer (this is barebones, no strict or anything... and *just* a snippet):
use POSIX; use File::lockf; $status = File::lockf::lock ($args); # replace $args as appropriate. if ($status) { # Uh oh, non zero value returned. # Lets use POSIX's errstr() to find out what happened $error_string = strerror ($status); die "Uh oh, lockf returned '$error_string'"; }

The real answer: flock

=)

Update: I forgot to mention, in this case, with a status of '9', the error is "Bad file descriptor". This means that something was wrong with your filehandle.

In reply to Re: File::lockf and the lock() return value by count0
in thread File::lockf and the lock() return value by SLG150

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.