-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.swp files can't be deleted because Vim is always PID 3 #47
Comments
I wonder if it would be possible to attach a second identifier to the PID. eg., a timestamp. However, I have no idea what the format of the |
If flatpak-specific handling is acceptable, maybe the |
An example of the error:
Here's the on-disk format. The pid field is a 4-byte int, like Turns out all the checks for the |
Oh, yes, this isn't just about the application process identifying itself. We also need to find out if there's any other process around matching the same identifier. Can we do the unthinkable and disable the PID namespace for Vim? :) The other application where I have come across this problem is Darktable, which also uses lock files containing the PID to gate access to the various databases. Unlike Vim, where being single-instance isn't trivial, I don't see why Darktable can't use D-Bus to ensure uniqueness. I see that it already claims |
On Wed, 3 Jul 2019, at 02:56, Debarshi Ray wrote:
Oh, yes, this isn't just about the application process identifying itself. We also need to find if there's any other process around matching the same identifier.
Can we do the unthinkable and disable the PID namespace for Vim? :)
This seems a little heavy-handed! :) How about making it so running the Vim Flatpak a second time reuses the sandboxes from the first, still-running instance? Not sure how hard this would be – `flatpak enter` can manage it though.
The other application where I have come across this problem is Darktable, which also uses lock files containing the PID to gate access to the various databases. Unlike Vim, where being single-instance isn't trivial,
Well, Vim actually does provide its own mechanism for something like this (`--remote` and `--serverlist` for reference) but it's a pain to use IME.
Maybe one could iterate each server and ask for its instance ID, but… by default, if you run Vim in non-GUI mode it doesn't make itself into a server. (I guess it uses X for IPC.)
|
If you open
foo.txt
in Vim, it writes.foo.txt.swp
alongside it. This file is used for crash recovery (among other things) and is removed when you close the file in Vim, or exit Vim cleanly. The file embeds the PID of the Vim process itself.When you open a file for which a
.swp
file already exists, Vim reads the PID from the file, and checks whether a Vim with that PID is running. If not, it offers you the option to delete the temporary file; if so, it says "(still running)" and won't let you delete it.However, the Flatpak is always launched in a new PID namespace, so (in practice) it's always PID 3. After a crash, the new Vim process looks for PID 3 and finds itself.
The text was updated successfully, but these errors were encountered: