On Tue, Aug 21, 2018 at 3:57 PM, Bram Moolenaar <[email protected]> wrote:
>
> Tony wrote:
>
>> If Vim is reloaded after a crash there will usually be one or more
>> ATTENTION (E325) messages. This is usually no problem for me as I save
>> my work at regular intervals, which means that I can usually delete
>> the swapfiles left standing after the crash (they will have "modified:
>> no"). However (especially after a system crash and a reboot) sometimes
>> the PID of the previous Vim has been reused, the ATTENTION message
>> says "(still running)" and the "delete" option is not available, even
>> though the program currently using that PID is not the Vim which
>> created the swapfile (and then crashed, or was involved in a system
>> crash). I'm not sure if (and how) it is possible to get over this
>> problem. Maybe in the (still running) case the ATTENTION message could
>> list the name of the program currently using that PID, and still offer
>> the "delete" option (possibly with an "are you sure" confirmation) if
>> that name isn't one of those (vim, gvim, view, etc.; even vi nowadays)
>> usually associated with a Vim executable?
>
> This is a corner case that is difficult to deal with.
> There is no standard way to get the name of a process from the pid.

Under Linux, on systems where the /proc filesystem is in use (which
IIUC is the general case), and if I represent the PID by $PID,
/proc/$PID/exe is a symlink to the executable, and /proc/$PID/cmdline
is a text file containing the $0, $1, etc. (the invoked executable
name and any command-line arguments), each of them null-terminated.
I'm not sure whether or not the /proc filesystem is in use on other
Unix-like systems (but I wouldn't bet against it), and of course on
Windows I suppose that even the existence of a given PID (the "(still
running)" part) must be got in a different way.

See "man 5 proc" and search (with less's regexps, very similar to
Vim's) for /proc/[pid]/cmdline and /proc/[pid]/exe

Best regards,
Tony.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui