]> granicus.if.org Git - vim/commitdiff
patch 9.0.1377: job_status() may return "dead" if the process parent changed v9.0.1377
authorBram Moolenaar <Bram@vim.org>
Sat, 4 Mar 2023 13:23:26 +0000 (13:23 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 4 Mar 2023 13:23:26 +0000 (13:23 +0000)
Problem:    job_status() may return "dead" if the process parent changed.
Solution:   Call mch_process_running() to check if the job is still alive.

src/os_unix.c
src/version.c

index 0dfbd497704920060029822c13bd492b32e543f8..b9514d24828040dd839b8c534751223815ca5b04 100644 (file)
@@ -5863,10 +5863,17 @@ mch_job_status(job_T *job)
 # endif
     if (wait_pid == -1)
     {
+       int waitpid_errno = errno;
+       if (waitpid_errno == ECHILD && mch_process_running(job->jv_pid))
+           // The process is alive, but it was probably reparented (for
+           // example by ptrace called by a debugger like lldb or gdb).
+           // Note: This assumes that process IDs are not reused.
+           return "run";
+
        // process must have exited
        if (job->jv_status < JOB_ENDED)
            ch_log(job->jv_channel, "Job no longer exists: %s",
-                                                             strerror(errno));
+                                                     strerror(waitpid_errno));
        goto return_dead;
     }
     if (wait_pid == 0)
index 022b9ffe87772f6e556f1ba87829b63d13542232..a9cf30e2f08013d946f70c6a458a14dfd00587e2 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1377,
 /**/
     1376,
 /**/