]> granicus.if.org Git - vim/commitdiff
patch 8.2.3041: detecting if the process of a swap file is running fails v8.2.3041
authorBram Moolenaar <Bram@vim.org>
Wed, 23 Jun 2021 19:13:20 +0000 (21:13 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 23 Jun 2021 19:13:20 +0000 (21:13 +0200)
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)

src/os_unix.c
src/version.c

index 0a4f0e6981cc4bc440e1f2f6c46f0fae8cdb3a54..56ee764b0f3ad467907dd95828416706cb9f400e 100644 (file)
@@ -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)
index bf3331238c75a05a9ebdc36eff23ad7587e806eb..79f05ccf78e3a3a7df6dfdd7cbe1a3dea73d9735 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3041,
 /**/
     3040,
 /**/