mirror of
https://github.com/neovim/neovim.git
synced 2024-12-25 21:55:17 -07:00
vim-patch:8.2.3041: detecting if the process of a swap file is running fails
Problem: Detecting if the process of a swap file is running fails if the
process is owned by another user.
Solution: Check for the ESRCH error. (closes vim/vim#8436)
44dea9da4b
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
1fe526184f
commit
a8489308ab
@ -264,5 +264,16 @@ Dictionary os_proc_info(int pid)
|
||||
/// Return true if process `pid` is running.
|
||||
bool os_proc_running(int pid)
|
||||
{
|
||||
return uv_kill(pid, 0) == 0;
|
||||
int err = uv_kill(pid, 0);
|
||||
// If there is no error the process must be running.
|
||||
if (err == 0) {
|
||||
return true;
|
||||
}
|
||||
// If the error is ESRCH then the process is not running.
|
||||
if (err == UV_ESRCH) {
|
||||
return false;
|
||||
}
|
||||
// If the process is running and owned by another user we get EPERM. With
|
||||
// other errors the process might be running, assuming it is then.
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user