diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-11-07 09:30:44 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-11-07 09:30:44 -0300 |
commit | 6f8c916d8408a89996ce8fbd86e48194b5a46b3e (patch) | |
tree | 98add394ba9ad6711af148a7ac24520cc9e79604 | |
parent | f7a468c1e76a1b2fb4ccf436fc9d50174b88b412 (diff) | |
parent | d3f81424e5a8de5d184f3ab3e14b632fa70f857d (diff) | |
download | rneovim-6f8c916d8408a89996ce8fbd86e48194b5a46b3e.tar.gz rneovim-6f8c916d8408a89996ce8fbd86e48194b5a46b3e.tar.bz2 rneovim-6f8c916d8408a89996ce8fbd86e48194b5a46b3e.zip |
Merge PR #1424 'Only force-close stdout/stderr when the job exits'
-rw-r--r-- | src/nvim/os/job.c | 6 | ||||
-rw-r--r-- | test/functional/job/job_spec.lua | 14 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/nvim/os/job.c b/src/nvim/os/job.c index 2f610cb51f..7ae2a86fc2 100644 --- a/src/nvim/os/job.c +++ b/src/nvim/os/job.c @@ -270,10 +270,10 @@ void job_stop(Job *job) } job->stopped_time = os_hrtime(); - // Close the standard streams of the job + // Close the job's stdin. If the job doesn't close it's own stdout/stderr, + // they will be closed when the job exits(possibly due to being terminated + // after a timeout) close_job_in(job); - close_job_out(job); - close_job_err(job); if (!stop_requests++) { // When there's at least one stop request pending, start a timer that diff --git a/test/functional/job/job_spec.lua b/test/functional/job/job_spec.lua index b2a65f8269..9046d85f10 100644 --- a/test/functional/job/job_spec.lua +++ b/test/functional/job/job_spec.lua @@ -15,6 +15,10 @@ describe('jobs', function() return "au! JobActivity xxx call rpcnotify("..channel..", "..expr..")" end + local notify_job = function() + return "au! JobActivity xxx call rpcnotify("..channel..", 'j', v:job_data)" + end + it('returns 0 when it fails to start', function() local status, rv = pcall(eval, "jobstart('', '')") eq(false, status) @@ -56,4 +60,14 @@ describe('jobs', function() it('will not cause a memory leak if we leave a job running', function() nvim('command', "call jobstart('xxx', 'cat', ['-'])") end) + + it('will only emit the "exit" event after "stdout" and "stderr"', function() + nvim('command', notify_job()) + nvim('command', "let j = jobstart('xxx', 'cat', ['-'])") + local jobid = nvim('eval', 'j') + nvim('eval', 'jobsend(j, "abc\ndef")') + nvim('eval', 'jobstop(j)') + eq({'notification', 'j', {{jobid, 'stdout', 'abc\ndef'}}}, next_message()) + eq({'notification', 'j', {{jobid, 'exit'}}}, next_message()) + end) end) |