summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-06-23 21:13:20 +0200
committerBram Moolenaar <Bram@vim.org>2021-06-23 21:13:20 +0200
commit44dea9da4b2a21dd1e03f2bd94b4f2679d4613e5 (patch)
tree19cdd3171b8e2e9907670ffe1a23e48017607322
parent18d46587b985923ef4b90b19a0cf37a094607fec (diff)
patch 8.2.3041: detecting if the process of a swap file is running failsv8.2.3041
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 #8436)
-rw-r--r--src/os_unix.c13
-rw-r--r--src/version.c2
2 files changed, 13 insertions, 2 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 0a4f0e6981..56ee764b0f 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -2486,8 +2486,17 @@ mch_get_pid(void)
int
mch_process_running(long pid)
{
- // EMX kill() not working correctly, it seems
- return kill(pid, 0) == 0;
+ // If there is no error the process must be running.
+ if (kill(pid, 0) == 0)
+ return TRUE;
+#ifdef ESRCH
+ // If the error is ESRCH then the process is not running.
+ if (errno == ESRCH)
+ return FALSE;
+#endif
+ // 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;
}
#if !defined(HAVE_STRERROR) && defined(USE_GETCWD)
diff --git a/src/version.c b/src/version.c
index bf3331238c..79f05ccf78 100644
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3041,
+/**/
3040,
/**/
3039,