patch 7.4.1306
Problem: Job control doesn't work well on MS-Windows.
Solution: Various fixes. (Ken Takata, Ozaki Kiichi , Yukihiro Nakadaira,
Yasuhiro Matsumoto)
diff --git a/src/os_unix.c b/src/os_unix.c
index 17bb322..83ae75f 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -5092,6 +5092,12 @@
job->jv_status = JOB_ENDED;
return "dead";
}
+ if (WIFSIGNALED(status))
+ {
+ job->jv_exitval = -1;
+ job->jv_status = JOB_ENDED;
+ return "dead";
+ }
return "run";
}
@@ -5099,6 +5105,7 @@
mch_stop_job(job_T *job, char_u *how)
{
int sig = -1;
+ pid_t job_pid;
if (STRCMP(how, "hup") == 0)
sig = SIGHUP;
@@ -5112,10 +5119,30 @@
sig = atoi((char *)how);
else
return FAIL;
+
/* TODO: have an option to only kill the process, not the group? */
- kill(-job->jv_pid, sig);
+ job_pid = job->jv_pid;
+ if (job_pid == getpgid(job_pid))
+ job_pid = -job_pid;
+
+ kill(job_pid, sig);
+
return OK;
}
+
+/*
+ * Clear the data related to "job".
+ */
+ void
+mch_clear_job(job_T *job)
+{
+ /* call waitpid because child process may become zombie */
+# ifdef __NeXT__
+ wait4(job->jv_pid, NULL, WNOHANG, (struct rusage *)0);
+# else
+ waitpid(job->jv_pid, NULL, WNOHANG);
+# endif
+}
#endif
/*