diff src/channel.c @ 15160:ec67c6b8ef12 v8.1.0590

patch 8.1.0590: when a job ends the closed channels are not handled commit https://github.com/vim/vim/commit/cd1a62d468a55aca68deb3139d83530c7c23568d Author: Bram Moolenaar <Bram@vim.org> Date: Fri Dec 14 21:32:02 2018 +0100 patch 8.1.0590: when a job ends the closed channels are not handled Problem: When a job ends the closed channels are not handled. Solution: When a job is detected to have ended, check the channels again. (closes #3530)
author Bram Moolenaar <Bram@vim.org>
date Fri, 14 Dec 2018 21:45:05 +0100
parents 6783403ff35e
children de63593896b3
line wrap: on
line diff
--- a/src/channel.c
+++ b/src/channel.c
@@ -5510,24 +5510,28 @@ has_pending_job(void)
 
 /*
  * Called once in a while: check if any jobs that seem useful have ended.
+ * Returns TRUE if a job did end.
  */
-    void
+    int
 job_check_ended(void)
 {
     int		i;
-
+    int		did_end = FALSE;
+
+    // be quick if there are no jobs to check
     if (first_job == NULL)
-	return;
+	return did_end;
 
     for (i = 0; i < MAX_CHECK_ENDED; ++i)
     {
-	/* NOTE: mch_detect_ended_job() must only return a job of which the
-	 * status was just set to JOB_ENDED. */
+	// NOTE: mch_detect_ended_job() must only return a job of which the
+	// status was just set to JOB_ENDED.
 	job_T	*job = mch_detect_ended_job(first_job);
 
 	if (job == NULL)
 	    break;
-	job_cleanup(job); /* may free "job" */
+	did_end = TRUE;
+	job_cleanup(job); // may free "job"
     }
 
     if (channel_need_redraw)
@@ -5535,6 +5539,7 @@ job_check_ended(void)
 	channel_need_redraw = FALSE;
 	redraw_after_callback(TRUE);
     }
+    return did_end;
 }
 
 /*