Because strings are immutable, this line rv = fcntl.fcntl(lock_file, fcntl.F_GETLK, flk) can't modify the value of flk. Instead, the value you want is returned in rv. Try changing the last 2 lines to locked = struct.unpack('hhllhl', rv)[0] print locked on my system, this prints 2, which is the value of F_UNLCK. Jeff