comparison src/os_unix.c @ 32092:60f330eb0376 v9.0.1377

patch 9.0.1377: job_status() may return "dead" if the process parent changed Commit: https://github.com/vim/vim/commit/5c6a3c9bad67c2ce766f55dbecb3461f14833a42 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 4 13:23:26 2023 +0000 patch 9.0.1377: job_status() may return "dead" if the process parent changed Problem: job_status() may return "dead" if the process parent changed. Solution: Call mch_process_running() to check if the job is still alive.
author Bram Moolenaar <Bram@vim.org>
date Sat, 04 Mar 2023 14:30:04 +0100
parents 3365a601e73b
children 04d9dff67d99
comparison
equal deleted inserted replaced
32091:136482cd3234 32092:60f330eb0376
5861 # else 5861 # else
5862 wait_pid = waitpid(job->jv_pid, &status, WNOHANG); 5862 wait_pid = waitpid(job->jv_pid, &status, WNOHANG);
5863 # endif 5863 # endif
5864 if (wait_pid == -1) 5864 if (wait_pid == -1)
5865 { 5865 {
5866 int waitpid_errno = errno;
5867 if (waitpid_errno == ECHILD && mch_process_running(job->jv_pid))
5868 // The process is alive, but it was probably reparented (for
5869 // example by ptrace called by a debugger like lldb or gdb).
5870 // Note: This assumes that process IDs are not reused.
5871 return "run";
5872
5866 // process must have exited 5873 // process must have exited
5867 if (job->jv_status < JOB_ENDED) 5874 if (job->jv_status < JOB_ENDED)
5868 ch_log(job->jv_channel, "Job no longer exists: %s", 5875 ch_log(job->jv_channel, "Job no longer exists: %s",
5869 strerror(errno)); 5876 strerror(waitpid_errno));
5870 goto return_dead; 5877 goto return_dead;
5871 } 5878 }
5872 if (wait_pid == 0) 5879 if (wait_pid == 0)
5873 return "run"; 5880 return "run";
5874 if (WIFEXITED(status)) 5881 if (WIFEXITED(status))