Article 5ECK5 nvi misteriously started opening the files in O_RDWR mode

nvi misteriously started opening the files in O_RDWR mode

by
louigi600
from LinuxQuestions.org on (#5ECK5)
Is there any particular reason why nvi should suddenly switch to permanently opening the scripts I'm editing in O_RDWR mode ?

I was doing my 2 terminal thing as usual: one with the editor on the scripts and the other for testing the script while editing.
Suddenly I started getting this message when I was attempting to run test the script:

Code:root@rpi4:~# ./spm "*sqlite3"
-bash: ./spm: /bin/bash: bad interpreter: Text file busy
root@rpi4:~#I was sure there was nothing wrong with the shebang and moreover the message disappears if i quit the nvi session on the script.
I also reproduced the problem on any given bash script on my system.

Out of desperation I switched back to elvis and the problem disappeared : what was nvi doing ? I spent quite some time searching if there was some setting that crept in to nvi but found nothing.

I found this thread that at least describes why it is happening ... and I did a strace to confirm that:

Code:openat(AT_FDCWD, "spm", O_RDWR) = 4
fcntl64(4, F_SETFD, FD_CLOEXEC) = 0
flock(4, LOCK_EX|LOCK_NB) = 0
access("spm", W_OK) = 0Is there any cure for this ?

Incidentally the normal output od the script is like this:
Code:root@rpi4:~# ./spm "*sqlite3"
/usr/bin/sqlite3 contained in sqlite-3.34.1-arm-1 [INSTALLED]
root@rpi4:~#I've sent Robby an issue on github ... maybe this functionality can be added to slackpkg since the file-search function in there is somewhat lacking wildchar management (the pertinent section for doing this is just 13 lines of script so nothing complicated):

Code:#find which package contains a file (absolute path with optional wildchars)
Find_Package_Owning_file ()
{ Regexp="$(sed 's?^/??; s?\*?.\*?g; s/?/./g' <<< $1)"
Info="$(bzcat $DB | awk -v filename="$Regexp" '
$2 ~ /Package:/ {package=$3; sub("./","",package)};
$NF ~ "^"filename"$" {printf("%s:/%s\n",package,$NF)} ')"

for hit in $Info
do
PackageInfo=${hit%%:*}
PackageFile=${PackageInfo##*/}
PackageName=${PackageFile%%.t*z}
File=${hit##*:}
[ -f ${InstalledPKGDir}/$PackageName ] && Installed="INSTALLED" || Installed="UNINSTALLED"
echo -e "$File contained in $PackageName [${Installed}]"
done
}I also made a function that will try to find for you the packages that contain your missing dll for any given file/package.
I made a blog about it here.latest?d=yIl2AUoC8zA latest?i=OG2c8qGfqWM:GxV6910hNyE:F7zBnMy latest?i=OG2c8qGfqWM:GxV6910hNyE:V_sGLiP latest?d=qj6IDK7rITs latest?i=OG2c8qGfqWM:GxV6910hNyE:gIN9vFwOG2c8qGfqWM
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments