vi — ‘already locked, session is read-only’
I recently came across this error in Vi after I was editing a file and was disconnect: “foo.txt already locked, session is read-only.” I thought it was a swp file issue of some sort, so I immediately searched for it to remove it. Only to find out that one didn’t exist.
So I did what most people do and searched Google for the solution. I was lead to a message board and found out that since I was disconnected, Vi had an open process of some sort still ‘editing’ the same file. The solution was simple. All you do is run a ps and grep for vi and kill the process. Here’s the command I ran:
ps -ef | grep vi
Once you get the pid, just kill it with, uhh, kill.
Done!