aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2016-11-17 08:53:05 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2016-11-17 15:13:45 +0100
commit1d4563771bcdaca0e6ec3eba1ca3ee6461d7afb5 (patch)
tree8526c2785d6bd60e9be469a650f486128be0300f
parent927e3e32d78460eb8031bda3304c9ea1f9ef855e (diff)
downloadrneovim-1d4563771bcdaca0e6ec3eba1ca3ee6461d7afb5.tar.gz
rneovim-1d4563771bcdaca0e6ec3eba1ca3ee6461d7afb5.tar.bz2
rneovim-1d4563771bcdaca0e6ec3eba1ca3ee6461d7afb5.zip
jobs: ensure calling jobclose() on a pty job sends SIGHUP. Closes #5619
-rw-r--r--runtime/doc/eval.txt3
-rw-r--r--src/nvim/eval.c3
-rw-r--r--test/functional/core/job_spec.lua6
3 files changed, 11 insertions, 1 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 64f58c5599..9c6cbd5a1a 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -4411,7 +4411,8 @@ jobclose({job}[, {stream}]) {Nvim} *jobclose()*
Close {job}'s {stream}, which can be one of "stdin", "stdout",
"stderr" or "rpc" (closes the rpc channel for a job started
with the "rpc" option.) If {stream} is omitted, all streams
- are closed.
+ are closed. If the job is a pty job, this will then close the
+ pty master, sending SIGHUP to the job process.
jobpid({job}) {Nvim} *jobpid()*
Return the pid (process id) of {job}.
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 87fe329ec2..750ef4f94f 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -11459,6 +11459,9 @@ static void f_jobclose(typval_T *argvars, typval_T *rettv, FunPtr fptr)
process_close_err(proc);
} else {
process_close_streams(proc);
+ if (proc->type == kProcessTypePty) {
+ pty_process_close_master(&data->proc.pty);
+ }
}
}
}
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index 5872ebe8ee..58594db8ac 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -480,6 +480,12 @@ describe('jobs', function()
nvim('command', 'call jobresize(j, 10, 40)')
eq('rows: 40, cols: 10', next_chunk())
end)
+
+ it('calling jobclose()', function()
+ -- this should send SIGHUP to the process
+ nvim('command', 'call jobclose(j)')
+ eq({'notification', 'exit', {0, 1}}, next_msg())
+ end)
end)
end)