summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2023-03-04 13:23:26 +0000
committerBram Moolenaar <Bram@vim.org>2023-03-04 13:23:26 +0000
commit5c6a3c9bad67c2ce766f55dbecb3461f14833a42 (patch)
tree821b3cf2c74239cdedfdfb9455232449a4753160
parent1c73b65229c25e3c1fd8824ba958f7cc4d604f9c (diff)
patch 9.0.1377: job_status() may return "dead" if the process parent changedv9.0.1377
Problem: job_status() may return "dead" if the process parent changed. Solution: Call mch_process_running() to check if the job is still alive.
-rw-r--r--src/os_unix.c9
-rw-r--r--src/version.c2
2 files changed, 10 insertions, 1 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 0dfbd49770..b9514d2482 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -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)
diff --git a/src/version.c b/src/version.c
index 022b9ffe87..a9cf30e2f0 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1377,
+/**/
1376,
/**/
1375,