http://www.perlmonks.org?node_id=228120


in reply to fcntl() madness with C and perl

The problem is your perl program, and it does not lock properly.

I tested the following perl code with your c code on AIX, and they worked with each other (compare my code with yours):
use strict; use Fcntl qw(SEEK_SET F_WRLCK F_UNLCK F_SETLKW); my($pack); open(FILE,">a"); $pack = pack('s s l l s', F_WRLCK, SEEK_SET, 0, 1, 0); print(fcntl(FILE, F_SETLKW, $pack) . "\n"); sleep(20); $pack = pack('s s l l s', F_UNLCK, SEEK_SET, 0, 1, 0); print(fcntl(FILE, F_SETLKW, $pack) . "\n"); close(FILE);