diff src/terminal.c @ 11919:cca097489de5 v8.0.0839

patch 8.0.0839: cannot kill a job in a terminal with CTRL-C commit https://github.com/vim/vim/commit/fae428354213b54626ff9e29faa5fd86161da942 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 1 22:24:26 2017 +0200 patch 8.0.0839: cannot kill a job in a terminal with CTRL-C Problem: Cannot kill a job in a terminal with CTRL-C. Solution: Set the controlling tty and send SIGINT. (closes https://github.com/vim/vim/issues/1910)
author Christian Brabandt <cb@256bit.org>
date Tue, 01 Aug 2017 22:30:04 +0200
parents 00836eb177cb
children c9da7b42fdf5
line wrap: on
line diff
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -39,8 +39,6 @@
  * - don't allow exiting Vim when a terminal is still running a job
  * - in bash mouse clicks are inserting characters.
  * - mouse scroll: when over other window, scroll that window.
- * - typing CTRL-C is not sent to the terminal.  need to setup controlling tty?
- *	#1910
  * - For the scrollback buffer store lines in the buffer, only attributes in
  *   tl_scrollback.
  * - When the job ends:
@@ -962,6 +960,17 @@ terminal_loop(void)
 	    /* job finished while waiting for a character */
 	    break;
 
+#ifdef UNIX
+	may_send_sigint(c, curbuf->b_term->tl_job->jv_pid, 0);
+#endif
+#ifdef WIN3264
+	if (c == Ctrl_C)
+	    /* We don't know if the job can handle CTRL-C itself or not, this
+	     * may kill the shell instead of killing the command running in the
+	     * shell. */
+	    mch_stop_job(curbuf->b_term->tl_job, "quit")
+#endif
+
 	if (c == (termkey == 0 ? Ctrl_W : termkey))
 	{
 	    int	    prev_c = c;