|XP is just a number|
With a fcntl lock, why this lsof output?by welchavw (Pilgrim)
|on Sep 23, 2005 at 21:28 UTC||Need Help??|
welchavw has asked for the
wisdom of the Perl Monks concerning the following question:
I am writing a small program (below) to enable me to replace the /etc/sudoers file (via an RPM), while respecting visudo and its file lock. (First thing, please note that the visudo man page, at least for my distro is wrong - there is no lock on /etc/sudoers.tmp AFAICT). I am doing this on x86 FC4 (so that you may grok the pack()). Basically, this program works - when I do a visudo after acquiring the lock through this program, it behaves just like 2 visudos were contending. That is, I get a "visudo: sudoers file busy, try again later." So all is swell, except I am picky and ...
I look at the output of "lsof -p" for visudo and compare the same output for the perl program.
When visudo is running, I get...
When the perl program is running (having gotten lock and is looping), I get...
See, the 3uW looks good for visudo, but where's the "W" to indicate write lock for the perl? Do I have a file lock, or is visudo failing to acquire the lock on /etc/sudoers for some other reason while this perl code is running?
So, I wonder if perhaps my pack is wrong and I am stomping on some memory. Or else something else is going on? Its too late on Friday for me to see what it is - maybe one of you monks can? (Pls don't kill me for the treatment of $rc - this code is just hacked together, thx).
Here's the program.