aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-11-17 18:41:07 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-11-17 18:44:05 +0800
commita8489308ab00f51bff197f29e76276b16ad0d985 (patch)
tree32391a56b562a308d00cde23df52c5aed0eb78c0
parent1fe526184f155bbda5d0d3037d683fd935b57c35 (diff)
downloadrneovim-a8489308ab00f51bff197f29e76276b16ad0d985.tar.gz
rneovim-a8489308ab00f51bff197f29e76276b16ad0d985.tar.bz2
rneovim-a8489308ab00f51bff197f29e76276b16ad0d985.zip
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) https://github.com/vim/vim/commit/44dea9da4b2a21dd1e03f2bd94b4f2679d4613e5 Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r--src/nvim/os/process.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/nvim/os/process.c b/src/nvim/os/process.c
index d9273e69da..f4d95e141b 100644
--- a/src/nvim/os/process.c
+++ b/src/nvim/os/process.c
@@ -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;
}