aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Blandy1992-10-31 04:53:11 +0000
committerJim Blandy1992-10-31 04:53:11 +0000
commitd177f1945894c62808329b22dcbaa56fdc5a5310 (patch)
treea287ca600f17106bd3b3b6f44e51e13683179400 /src
parent3b1f62f3ac250a59017f10c89e951dae7795e6b6 (diff)
downloademacs-d177f1945894c62808329b22dcbaa56fdc5a5310.tar.gz
emacs-d177f1945894c62808329b22dcbaa56fdc5a5310.zip
* 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.
Diffstat (limited to 'src')
-rw-r--r--src/callproc.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/callproc.c b/src/callproc.c
index 779d16faaad..19bd7f3e386 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -49,6 +49,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
49#include "buffer.h" 49#include "buffer.h"
50#include "paths.h" 50#include "paths.h"
51#include "process.h" 51#include "process.h"
52#include "syssignal.h"
52 53
53#ifdef VMS 54#ifdef VMS
54extern noshare char **environ; 55extern noshare char **environ;
@@ -77,16 +78,36 @@ int synch_process_retcode;
77 78
78#ifndef VMS /* VMS version is in vmsproc.c. */ 79#ifndef VMS /* VMS version is in vmsproc.c. */
79 80
81static Lisp_Object
82call_process_kill (fdpid)
83 Lisp_Object fdpid;
84{
85 close (XFASTINT (Fcar (fdpid)));
86 EMACS_KILLPG (XFASTINT (Fcdr (fdpid)), SIGKILL);
87 synch_process_alive = 0;
88 return Qnil;
89}
90
80Lisp_Object 91Lisp_Object
81call_process_cleanup (fdpid) 92call_process_cleanup (fdpid)
82 Lisp_Object fdpid; 93 Lisp_Object fdpid;
83{ 94{
84 register Lisp_Object fd, pid; 95 register int pid = XFASTINT (Fcdr (fdpid));
85 fd = Fcar (fdpid); 96
86 pid = Fcdr (fdpid); 97 if (EMACS_KILLPG (pid, SIGINT) == 0)
87 close (XFASTINT (fd)); 98 {
88 kill (XFASTINT (pid), SIGKILL); 99 int count = specpdl_ptr - specpdl;
100 record_unwind_protect (call_process_kill, fdpid);
101 message1 ("Waiting for process to die...(type C-g again to kill it instantly)");
102 immediate_quit = 1;
103 QUIT;
104 wait_for_termination (pid);
105 immediate_quit = 0;
106 specpdl_ptr = specpdl + count; /* Discard the unwind protect. */
107 message1 ("Waiting for process to die...done");
108 }
89 synch_process_alive = 0; 109 synch_process_alive = 0;
110 close (XFASTINT (Fcar (fdpid)));
90 return Qnil; 111 return Qnil;
91} 112}
92 113
@@ -100,7 +121,7 @@ Remaining arguments are strings passed as command arguments to PROGRAM.\n\
100If BUFFER is 0, returns immediately with value nil.\n\ 121If BUFFER is 0, returns immediately with value nil.\n\
101Otherwise waits for PROGRAM to terminate\n\ 122Otherwise waits for PROGRAM to terminate\n\
102and returns a numeric exit status or a signal description string.\n\ 123and returns a numeric exit status or a signal description string.\n\
103If you quit, the process is killed with SIGKILL.") 124If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.")
104 (nargs, args) 125 (nargs, args)
105 int nargs; 126 int nargs;
106 register Lisp_Object *args; 127 register Lisp_Object *args;
@@ -312,7 +333,7 @@ Remaining args are passed to PROGRAM at startup as command args.\n\
312If BUFFER is nil, returns immediately with value nil.\n\ 333If BUFFER is nil, returns immediately with value nil.\n\
313Otherwise waits for PROGRAM to terminate\n\ 334Otherwise waits for PROGRAM to terminate\n\
314and returns a numeric exit status or a signal description string.\n\ 335and returns a numeric exit status or a signal description string.\n\
315If you quit, the process is killed with SIGKILL.") 336If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.")
316 (nargs, args) 337 (nargs, args)
317 int nargs; 338 int nargs;
318 register Lisp_Object *args; 339 register Lisp_Object *args;