diff --git a/src/process.c b/src/process.c index 1900951533..e7ee99ab3d 100644 --- a/src/process.c +++ b/src/process.c @@ -6677,6 +6677,18 @@ process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group, unblock_child_signal (&oldset); } +DEFUN ("internal-default-interrupt-process", + Finternal_default_interrupt_process, + Sinternal_default_interrupt_process, 0, 2, 0, + doc: /* Default function to interrupt process PROCESS. +It shall be the last element in list `interrupt-process-functions'. +See function `interrupt-process' for more details on usage. */) + (Lisp_Object process, Lisp_Object current_group) +{ + process_send_signal (process, SIGINT, current_group, 0); + return process; +} + DEFUN ("interrupt-process", Finterrupt_process, Sinterrupt_process, 0, 2, 0, doc: /* Interrupt process PROCESS. PROCESS may be a process, a buffer, or the name of a process or buffer. @@ -6688,11 +6700,14 @@ If the process is a shell, this means interrupt current subjob rather than the shell. If CURRENT-GROUP is `lambda', and if the shell owns the terminal, -don't send the signal. */) +don't send the signal. + +This function calls the functions of `interrupt-process-functions' in +the order of the list, until one of them returns non-`nil'. */) (Lisp_Object process, Lisp_Object current_group) { - process_send_signal (process, SIGINT, current_group, 0); - return process; + return CALLN (Frun_hook_with_args_until_success, Qinterrupt_process_functions, + process, current_group); } DEFUN ("kill-process", Fkill_process, Skill_process, 0, 2, 0, @@ -8176,6 +8191,17 @@ non-nil value means that the delay is not reset on write. The variable takes effect when `start-process' is called. */); Vprocess_adaptive_read_buffering = Qt; + DEFVAR_LISP ("interrupt-process-functions", Vinterrupt_process_functions, + doc: /* List of functions to be called for `interrupt-function'. +The arguments of the functions are the same as for `interrupt-function'. +These functions are called in the order of the list, until one of them +returns non-`nil'. */); + Vinterrupt_process_functions = list1 (Qinternal_default_interrupt_process); + + DEFSYM (Qinternal_default_interrupt_process, + "internal-default-interrupt-process"); + DEFSYM (Qinterrupt_process_functions, "interrupt-process-functions"); + defsubr (&Sprocessp); defsubr (&Sget_process); defsubr (&Sdelete_process); @@ -8218,6 +8244,7 @@ The variable takes effect when `start-process' is called. */); defsubr (&Saccept_process_output); defsubr (&Sprocess_send_region); defsubr (&Sprocess_send_string); + defsubr (&Sinternal_default_interrupt_process); defsubr (&Sinterrupt_process); defsubr (&Skill_process); defsubr (&Squit_process);