diff options
| author | Jim Blandy | 1992-10-31 04:53:11 +0000 |
|---|---|---|
| committer | Jim Blandy | 1992-10-31 04:53:11 +0000 |
| commit | d177f1945894c62808329b22dcbaa56fdc5a5310 (patch) | |
| tree | a287ca600f17106bd3b3b6f44e51e13683179400 /src | |
| parent | 3b1f62f3ac250a59017f10c89e951dae7795e6b6 (diff) | |
| download | emacs-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.c | 35 |
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 |
| 54 | extern noshare char **environ; | 55 | extern 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 | ||
| 81 | static Lisp_Object | ||
| 82 | call_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 | |||
| 80 | Lisp_Object | 91 | Lisp_Object |
| 81 | call_process_cleanup (fdpid) | 92 | call_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\ | |||
| 100 | If BUFFER is 0, returns immediately with value nil.\n\ | 121 | If BUFFER is 0, returns immediately with value nil.\n\ |
| 101 | Otherwise waits for PROGRAM to terminate\n\ | 122 | Otherwise waits for PROGRAM to terminate\n\ |
| 102 | and returns a numeric exit status or a signal description string.\n\ | 123 | and returns a numeric exit status or a signal description string.\n\ |
| 103 | If you quit, the process is killed with SIGKILL.") | 124 | If 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\ | |||
| 312 | If BUFFER is nil, returns immediately with value nil.\n\ | 333 | If BUFFER is nil, returns immediately with value nil.\n\ |
| 313 | Otherwise waits for PROGRAM to terminate\n\ | 334 | Otherwise waits for PROGRAM to terminate\n\ |
| 314 | and returns a numeric exit status or a signal description string.\n\ | 335 | and returns a numeric exit status or a signal description string.\n\ |
| 315 | If you quit, the process is killed with SIGKILL.") | 336 | If 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; |