aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/process.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-11-17 19:38:57 +0800
committerGitHub <noreply@github.com>2022-11-17 19:38:57 +0800
commit0a4c5cd2b2b7d98dc0930c474a347dee9f09bfad (patch)
tree5a6f8493d3be7dd9fc882238394cafdc62295999 /src/nvim/os/process.c
parent98bcf49d2692af1f2c21f6d10fd056855d4ea238 (diff)
parent78998bc6c6dcd6945e39f427520f6851707eb344 (diff)
downloadrneovim-0a4c5cd2b2b7d98dc0930c474a347dee9f09bfad.tar.gz
rneovim-0a4c5cd2b2b7d98dc0930c474a347dee9f09bfad.tar.bz2
rneovim-0a4c5cd2b2b7d98dc0930c474a347dee9f09bfad.zip
Merge pull request #21087 from zeertzjq/vim-8.2.1970
vim-patch:8.2.{1970,2016,2019,2026,2044,3041,3042}: check if process of swap file is still running
Diffstat (limited to 'src/nvim/os/process.c')
-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;
}