in reply to fcntl failure after eval

I ran your code on my system with perl-5.10.0, perl-5.11.0, perl-5.11.3, perl-5.11.4, perl-5.12.0 and perl-5.13.8 and all behave as expected.

I also tested it on another debian machine with perl-5.10.0 and that behaves as expected as well.

This of course does not tell that much since you are using perl-5.10.1 with different ./Configure options and with different patches...

What I suggest: install strace and strace the program to see what the system fcntl call really returns.

A second suggestion, maybe more complex, is to install a stock perl-5.10.1 (without patches that is) and attempt to reproduce it with that.

Update (2011-08-22 07:09 UTC): I ran my tests on 32 bit systems; running it on a 64 bit system confirms the same problem

Replies are listed 'Best First'.
Re^2: fcntl failure after eval
by flipper (Beadle) on Aug 11, 2011 at 19:26 UTC

    Something utterly bizarre is going on - if I add a line warn "flags '$flags'"; in lockf() just above the return statement, it works, even with the eval!

    It happens on different machines, all debian stable 64bit . I will try a vanilla perl tomorrow. From strace, the length parameter which I'm trying to pass through pack as 0 is (sometimes) corrupted. strace when it goes wrong:

    root@geedorah:~# strace perl foo.pl 2>&1 |grep fcntl fcntl(3, F_SETFD, FD_CLOEXEC) = 0 fcntl(3, F_SETFD, FD_CLOEXEC) = 0 fcntl(3, F_SETLK, {type=F_WRLCK, whence=SEEK_SET, start=0, len=-858311 +8848}) = -1 EINVAL (Invalid argument) fcntl(3, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0 root@geedorah:~#
    And when it goes right:
    root@geedorah:~# strace perl foo.pl 2>&1 |grep fcntl fcntl(3, F_SETFD, FD_CLOEXEC) = 0 fcntl(3, F_SETFD, FD_CLOEXEC) = 0 fcntl(3, F_SETLK, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}) = 0 fcntl(3, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0