Subject: | Editing test report using vi under FreeBSD |
Following is the usual flow when trying to edit a test report on a
FreeBSD system:
Do you want to review or edit the test report? (yes/no) [no] yes
Editor [vi]:
/tmp/lO7QPjCGeR.txt already locked, session is read-only.
/tmp/lO7QPjCGeR.txt: unmodified, readonly: line 1
Press any key to continue:
It is still possible to edit and save the report, but one has to force
vi to do so.
The reason is probably caused by the exlock feature in File::Temp. On
operating systems where O_EXLOCK is supported (i.e. BSD systems) it will
be used by default. This exclusive lock causes problems because vi seems
to lock the file itself. The File::Temp documentation suggest to use the
EXLOCK => 0 option in these cases.
Here's a the lsof output of the temporary edit file. One can see the
lock hold by perl:
$ lsof /tmp/SL0Pty09z4.txt
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
perl5.8.8 13314 cpansand 3uW VREG 0,135 8077 29
/tmp/SL0Pty09z4.txt
vi 26270 cpansand 3r VREG 0,135 8077 29
/tmp/SL0Pty09z4.txt
Regards,
Slaven