@@ -4194,6 +4194,26 @@ open_pty(int *pty_master_fd, int *pty_slave_fd)
41944194}
41954195#endif
41964196
4197+ /*
4198+ * Send SIGINT to a child process if "c" is an interrupt character.
4199+ */
4200+ void
4201+ may_send_sigint (int c UNUSED , pid_t pid UNUSED , pid_t wpid UNUSED )
4202+ {
4203+ # ifdef SIGINT
4204+ if (c == Ctrl_C || c == intr_char )
4205+ {
4206+ # ifdef HAVE_SETSID
4207+ kill (- pid , SIGINT );
4208+ # else
4209+ kill (0 , SIGINT );
4210+ # endif
4211+ if (wpid > 0 )
4212+ kill (wpid , SIGINT );
4213+ }
4214+ # endif
4215+ }
4216+
41974217 int
41984218mch_call_shell (
41994219 char_u * cmd ,
@@ -4765,23 +4785,12 @@ mch_call_shell(
47654785 */
47664786 if (len == 1 && (pty_master_fd < 0 || cmd != NULL ))
47674787 {
4768- # ifdef SIGINT
47694788 /*
47704789 * Send SIGINT to the child's group or all
47714790 * processes in our group.
47724791 */
4773- if (ta_buf [ta_len ] == Ctrl_C
4774- || ta_buf [ta_len ] == intr_char )
4775- {
4776- # ifdef HAVE_SETSID
4777- kill (- pid , SIGINT );
4778- # else
4779- kill (0 , SIGINT );
4780- # endif
4781- if (wpid > 0 )
4782- kill (wpid , SIGINT );
4783- }
4784- # endif
4792+ may_send_sigint (ta_buf [ta_len ], pid , wpid );
4793+
47854794 if (pty_master_fd < 0 && toshell_fd >= 0
47864795 && ta_buf [ta_len ] == Ctrl_D )
47874796 {
@@ -5360,15 +5369,26 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options)
53605369 if (null_fd >= 0 )
53615370 close (null_fd );
53625371
5372+ if (pty_slave_fd >= 0 )
5373+ {
5374+ /* push stream discipline modules */
5375+ SetupSlavePTY (pty_slave_fd );
5376+ # ifdef TIOCSCTTY
5377+ /* Try to become controlling tty (probably doesn't work,
5378+ * unless run by root) */
5379+ ioctl (pty_slave_fd , TIOCSCTTY , (char * )NULL );
5380+ # endif
5381+ }
5382+
53635383 /* See above for type of argv. */
53645384 execvp (argv [0 ], argv );
53655385
53665386 if (stderr_works )
53675387 perror ("executing job failed" );
5368- #ifdef EXITFREE
5388+ # ifdef EXITFREE
53695389 /* calling free_all_mem() here causes problems. Ignore valgrind
53705390 * reporting possibly leaked memory. */
5371- #endif
5391+ # endif
53725392 _exit (EXEC_FAILED ); /* exec failed, return failure code */
53735393 }
53745394
0 commit comments