diff src/eval.c @ 8259:99a70c3b902f v7.4.1422

commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 26 11:17:46 2016 +0100 patch 7.4.1422 Problem: Error when reading fails uses wrong errno. Keeping channel open after job stops results in test failing. Solution: Move the error up. Add ch_job_killed.
author Christian Brabandt <cb@256bit.org>
date Fri, 26 Feb 2016 11:30:05 +0100
parents c4ffdda8cdfd
children 108d30ed34ba
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -7770,8 +7770,11 @@ job_free(job_T *job)
 # ifdef FEAT_CHANNEL
     if (job->jv_channel != NULL)
     {
-	/* The channel doesn't count as a references for the job, we need to
-	 * NULL the reference when the job is freed. */
+	/* The link from the channel to the job doesn't count as a reference,
+	 * thus don't decrement the refcount of the job.  The reference from
+	 * the job to the channel does count the refrence, decrement it and
+	 * NULL the reference.  We don't set ch_job_killed, unreferencing the
+	 * job doesn't mean it stops running. */
 	job->jv_channel->ch_job = NULL;
 	channel_unref(job->jv_channel);
     }
@@ -15161,7 +15164,14 @@ f_job_stop(typval_T *argvars UNUSED, typ
 	if (mch_stop_job(job, arg) == FAIL)
 	    rettv->vval.v_number = 0;
 	else
+	{
 	    rettv->vval.v_number = 1;
+	    /* Assume that "hup" does not kill the job. */
+	    if (job->jv_channel != NULL && STRCMP(arg, "hup") != 0)
+		job->jv_channel->ch_job_killed = TRUE;
+	}
+	/* We don't try freeing the job, obviously the caller still has a
+	 * reference to it. */
     }
 }
 #endif