# HG changeset patch # User Jim Blandy # Date 720507191 0 # Node ID e074a2236b0010c6603d64524d1184379e5ba270 # Parent 3ad82148830b89639a3f153b7a57b674a6f57b7c * callproc.c: Arrange for synchronous processes to get SIGINT the first time the user quits, or SIGKILL if the user quits again. #include "syssignal.h". (call_process_kill): New function. (call_process_cleanup): Send SIGINT to the subprocess, and then arrange to call call_process_kill if the user quits while we wait for it to terminate. (Fcall_process, Fcall_process_region): Doc fix. diff -r 3ad82148830b -r e074a2236b00 src/callproc.c --- a/src/callproc.c Sat Oct 31 04:52:24 1992 +0000 +++ b/src/callproc.c Sat Oct 31 04:53:11 1992 +0000 @@ -49,6 +49,7 @@ #include "buffer.h" #include "paths.h" #include "process.h" +#include "syssignal.h" #ifdef VMS extern noshare char **environ; @@ -77,16 +78,36 @@ #ifndef VMS /* VMS version is in vmsproc.c. */ +static Lisp_Object +call_process_kill (fdpid) + Lisp_Object fdpid; +{ + close (XFASTINT (Fcar (fdpid))); + EMACS_KILLPG (XFASTINT (Fcdr (fdpid)), SIGKILL); + synch_process_alive = 0; + return Qnil; +} + Lisp_Object call_process_cleanup (fdpid) Lisp_Object fdpid; { - register Lisp_Object fd, pid; - fd = Fcar (fdpid); - pid = Fcdr (fdpid); - close (XFASTINT (fd)); - kill (XFASTINT (pid), SIGKILL); + register int pid = XFASTINT (Fcdr (fdpid)); + + if (EMACS_KILLPG (pid, SIGINT) == 0) + { + int count = specpdl_ptr - specpdl; + record_unwind_protect (call_process_kill, fdpid); + message1 ("Waiting for process to die...(type C-g again to kill it instantly)"); + immediate_quit = 1; + QUIT; + wait_for_termination (pid); + immediate_quit = 0; + specpdl_ptr = specpdl + count; /* Discard the unwind protect. */ + message1 ("Waiting for process to die...done"); + } synch_process_alive = 0; + close (XFASTINT (Fcar (fdpid))); return Qnil; } @@ -100,7 +121,7 @@ If BUFFER is 0, returns immediately with value nil.\n\ Otherwise waits for PROGRAM to terminate\n\ and returns a numeric exit status or a signal description string.\n\ -If you quit, the process is killed with SIGKILL.") +If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") (nargs, args) int nargs; register Lisp_Object *args; @@ -312,7 +333,7 @@ If BUFFER is nil, returns immediately with value nil.\n\ Otherwise waits for PROGRAM to terminate\n\ and returns a numeric exit status or a signal description string.\n\ -If you quit, the process is killed with SIGKILL.") +If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") (nargs, args) int nargs; register Lisp_Object *args;