in reply to
Re^2: What the flock!? Concurrency issues in file writing.
in thread What the flock!? Concurrency issues in file writing.
As I mentioned before you must put a sysseek in there (e.g. after the flock, but before the syswrite). If you don't you will see corruption since a single process will have a stale version of the current EOF for it's file descriptor.
I also see corruption with your code on my mac. I don't see it if there is a sysseek($FH, 0, 2). You mentioned that sysseek() "broke everything". When you put it back in this code, and check for error returns, what do you see?