This does look like the right answer.

There are 3 different cases to consider:

  1. a 32 bit system with large file support (-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64)
  2. a 32 bit system without large file support
  3. a 64 bit system

ikegami's c program for each of the three:

  1. 32 bit system with LFS:
    $ gcc -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wall a.c -o a && a
    flock:          24
    flock.l_type:   2 @  0
    flock.l_whence: 2 @  2
    flock.l_start:  8 @  4
    flock.l_len:    8 @ 12
    flock.l_pid:    4 @ 20
    
  2. 32 bit system without LFS:
    $ gcc  -Wall a.c -o a && a
    flock:          16
    flock.l_type:   2 @  0
    flock.l_whence: 2 @  2
    flock.l_start:  4 @  4
    flock.l_len:    4 @  8
    flock.l_pid:    4 @ 12
    
  3. 64 bit system:
    $ gcc  -Wall a.c -o a && a
    flock:          32
    flock.l_type:   2 @  0
    flock.l_whence: 2 @  2
    flock.l_start:  8 @  8
    flock.l_len:    8 @ 16
    flock.l_pid:    4 @ 24
    

The test perls:

  1. stock perl-5.10.0, running on a 32 bit system with large file support
  2. debian perl-5.10.0, running on a 32 bit system with large file support
  3. debian perl-5.10.1, running on a 64 bit system

Changing the op's code to:

What this all means is that the value you need for $flags depends highly on the system it is running.. Which makes me wonder wheter or not there is a better way to accomplish what the op wants..


In reply to Re^3: fcntl failure after eval by Animator
in thread fcntl failure after eval by flipper

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.