The issue is that you use fcntl to get a byte-level write lock (the lowercase w) while visudo uses flock or lockf (depending on what you have) to lock the whole file (uppercase W). The lowercase u is because visudo opens the file read-write and you open it for append.
HTH, --traveler
Comment on Re: With a fcntl lock, why this lsof output?
Perfect. Thank you. I grabbed File::lockf and was indeed able to see that lockf with a "+<" mode open exactly replicates the visudo locking. I had never ventured into deeply enough into file-locking to learn of the multiple APIs and their differences.