This is a follow up to this question: Why doesn't vim always give me the option to delete a swap file?
My laptop died with some Vim sessions open. These were all files I had already saved, so I don't need the swap files, but the "Delete" option isn't present when I edit some of them. As described in the question above, Vim thinks the previous process is still running:
Found a swap file by the name "~/.vim/tmp//%home%dominickpastore%research%codegen%rabbitmq.c.swp"
owned by: dominickpastore dated: Tue May 12 13:56:53 2020
file name: ~dominickpastore/research/codegen/rabbitmq.c
modified: no
user name: dominickpastore host name: carbon
process ID: 8903 (still running)
While opening file "rabbitmq.c"
dated: Tue May 12 13:56:49 2020
The thing is, my laptop was fully dead, so I know for a fact that the previous process is not still running! And just to be sure, I checked if there is another process with that PID, and there is not.
Interestingly, it only did this for 2 of 5 files I had open (all in different instances of Vim). It properly recognized the other 3 as gone.
How does Vim determine if the previous process is still running? Why is it sometimes mistaken?
ps -f -p <pid>and always shows as still running in Vim, until I delete the swapfile. I've even checked while the new Vim instance was still running in case the new instance happened to have the same PID. – Dominick Pastore May 15 '20 at 13:44kill -0 8903to check whether a process is alive (you can use that command line to see if your shell agrees.) See this question for an example of listing thread ids and napping them back to PIDs. – filbranden May 17 '20 at 16:55