diff options
| author | Richard M. Stallman | 1994-09-23 22:28:08 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-09-23 22:28:08 +0000 |
| commit | 3b9a3dfaeeb7394591c3aa347ee0cde1b70d3f6b (patch) | |
| tree | b5e62d382c0033bd85e57e62d439190d00c07618 | |
| parent | 080c45fd0b8ce128a681ebf772fcb07048cde4eb (diff) | |
| download | emacs-3b9a3dfaeeb7394591c3aa347ee0cde1b70d3f6b.tar.gz emacs-3b9a3dfaeeb7394591c3aa347ee0cde1b70d3f6b.zip | |
(exec_sentinel_error_handler): New function.
(exec_sentinel): Catch all errors in the sentinel.
(read_process_output_error_handler): New function.
(read_process_output_call): New function.
(read_process_output): Catch and report errors in filters.
(pty_name): Move it up; make it static.
(create_process): Set the tty_name field.
(Fprocess_tty_name): New function.
(syms_of_process): defsubr it.
| -rw-r--r-- | src/process.c | 73 |
1 files changed, 64 insertions, 9 deletions
diff --git a/src/process.c b/src/process.c index 5f2cfd0a07b..04907a47031 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -253,6 +253,13 @@ static Lisp_Object get_process (); | |||
| 253 | 253 | ||
| 254 | /* Maximum number of bytes to send to a pty without an eof. */ | 254 | /* Maximum number of bytes to send to a pty without an eof. */ |
| 255 | static int pty_max_bytes; | 255 | static int pty_max_bytes; |
| 256 | |||
| 257 | /* Open an available pty, returning a file descriptor. | ||
| 258 | Return -1 on failure. | ||
| 259 | The file name of the terminal corresponding to the pty | ||
| 260 | is left in the variable pty_name. */ | ||
| 261 | |||
| 262 | static char pty_name[24]; | ||
| 256 | 263 | ||
| 257 | /* Compute the Lisp form of the process status, p->status, from | 264 | /* Compute the Lisp form of the process status, p->status, from |
| 258 | the numeric status that was returned by `wait'. */ | 265 | the numeric status that was returned by `wait'. */ |
| @@ -361,13 +368,6 @@ status_message (status) | |||
| 361 | 368 | ||
| 362 | #ifdef HAVE_PTYS | 369 | #ifdef HAVE_PTYS |
| 363 | 370 | ||
| 364 | /* Open an available pty, returning a file descriptor. | ||
| 365 | Return -1 on failure. | ||
| 366 | The file name of the terminal corresponding to the pty | ||
| 367 | is left in the variable pty_name. */ | ||
| 368 | |||
| 369 | char pty_name[24]; | ||
| 370 | |||
| 371 | int | 371 | int |
| 372 | allocate_pty () | 372 | allocate_pty () |
| 373 | { | 373 | { |
| @@ -705,6 +705,17 @@ For a non-child channel, this is nil.") | |||
| 705 | return XPROCESS (proc)->command; | 705 | return XPROCESS (proc)->command; |
| 706 | } | 706 | } |
| 707 | 707 | ||
| 708 | DEFUN ("process-tty-name", Fprocess_tty_name, Sprocess_tty_name, 1, 1, 0, | ||
| 709 | "Return the name of the terminal PROCESS uses, or nil if none.\n\ | ||
| 710 | This is the terminal that the process itself reads and writes on,\n\ | ||
| 711 | not the name of the pty that Emacs uses to talk with that terminal.") | ||
| 712 | (proc) | ||
| 713 | register Lisp_Object proc; | ||
| 714 | { | ||
| 715 | CHECK_PROCESS (proc, 0); | ||
| 716 | return XPROCESS (proc)->tty_name; | ||
| 717 | } | ||
| 718 | |||
| 708 | DEFUN ("set-process-buffer", Fset_process_buffer, Sset_process_buffer, | 719 | DEFUN ("set-process-buffer", Fset_process_buffer, Sset_process_buffer, |
| 709 | 2, 2, 0, | 720 | 2, 2, 0, |
| 710 | "Set buffer associated with PROCESS to BUFFER (a buffer, or nil).") | 721 | "Set buffer associated with PROCESS to BUFFER (a buffer, or nil).") |
| @@ -1445,6 +1456,8 @@ create_process (process, new_argv, current_dir) | |||
| 1445 | if (forkin != forkout && forkout >= 0) | 1456 | if (forkin != forkout && forkout >= 0) |
| 1446 | close (forkout); | 1457 | close (forkout); |
| 1447 | 1458 | ||
| 1459 | XPROCESS (process)->tty_name = build_string (pty_name); | ||
| 1460 | |||
| 1448 | #ifdef SIGCHLD | 1461 | #ifdef SIGCHLD |
| 1449 | #ifdef BSD4_1 | 1462 | #ifdef BSD4_1 |
| 1450 | sigrelse (SIGCHLD); | 1463 | sigrelse (SIGCHLD); |
| @@ -2177,6 +2190,25 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 2177 | return got_some_input; | 2190 | return got_some_input; |
| 2178 | } | 2191 | } |
| 2179 | 2192 | ||
| 2193 | /* Given a list (FUNCTION ARGS...), apply FUNCTION to the ARGS. */ | ||
| 2194 | |||
| 2195 | static Lisp_Object | ||
| 2196 | read_process_output_call (fun_and_args) | ||
| 2197 | Lisp_Object fun_and_args; | ||
| 2198 | { | ||
| 2199 | return apply1 (XCONS (fun_and_args)->car, XCONS (fun_and_args)->cdr); | ||
| 2200 | } | ||
| 2201 | |||
| 2202 | static Lisp_Object | ||
| 2203 | read_process_output_error_handler (error) | ||
| 2204 | Lisp_Object error; | ||
| 2205 | { | ||
| 2206 | cmd_error_internal (error, "error in process filter: "); | ||
| 2207 | Vinhibit_quit = Qt; | ||
| 2208 | update_echo_area (); | ||
| 2209 | Fsleep_for (make_number (2)); | ||
| 2210 | } | ||
| 2211 | |||
| 2180 | /* Read pending output from the process channel, | 2212 | /* Read pending output from the process channel, |
| 2181 | starting with our buffered-ahead character if we have one. | 2213 | starting with our buffered-ahead character if we have one. |
| 2182 | Yield number of characters read. | 2214 | Yield number of characters read. |
| @@ -2253,7 +2285,14 @@ read_process_output (proc, channel) | |||
| 2253 | 2285 | ||
| 2254 | specbind (Qinhibit_quit, Qt); | 2286 | specbind (Qinhibit_quit, Qt); |
| 2255 | specbind (Qlast_nonmenu_event, Qt); | 2287 | specbind (Qlast_nonmenu_event, Qt); |
| 2256 | call2 (outstream, proc, make_string (chars, nchars)); | 2288 | |
| 2289 | internal_condition_case_1 (read_process_output_call, | ||
| 2290 | Fcons (outstream, | ||
| 2291 | Fcons (proc, | ||
| 2292 | Fcons (make_string (chars, nchars), | ||
| 2293 | Qnil))), | ||
| 2294 | !NILP (Vdebug_on_error) ? Qnil : Qerror, | ||
| 2295 | read_process_output_error_handler); | ||
| 2257 | 2296 | ||
| 2258 | /* Handling the process output should not deactivate the mark. */ | 2297 | /* Handling the process output should not deactivate the mark. */ |
| 2259 | Vdeactivate_mark = odeactivate; | 2298 | Vdeactivate_mark = odeactivate; |
| @@ -3094,6 +3133,16 @@ exec_sentinel_unwind (data) | |||
| 3094 | return Qnil; | 3133 | return Qnil; |
| 3095 | } | 3134 | } |
| 3096 | 3135 | ||
| 3136 | static Lisp_Object | ||
| 3137 | exec_sentinel_error_handler (error) | ||
| 3138 | Lisp_Object error; | ||
| 3139 | { | ||
| 3140 | cmd_error_internal (error, "error in process sentinel: "); | ||
| 3141 | Vinhibit_quit = Qt; | ||
| 3142 | update_echo_area (); | ||
| 3143 | Fsleep_for (make_number (2)); | ||
| 3144 | } | ||
| 3145 | |||
| 3097 | static void | 3146 | static void |
| 3098 | exec_sentinel (proc, reason) | 3147 | exec_sentinel (proc, reason) |
| 3099 | Lisp_Object proc, reason; | 3148 | Lisp_Object proc, reason; |
| @@ -3115,7 +3164,12 @@ exec_sentinel (proc, reason) | |||
| 3115 | /* Inhibit quit so that random quits don't screw up a running filter. */ | 3164 | /* Inhibit quit so that random quits don't screw up a running filter. */ |
| 3116 | specbind (Qinhibit_quit, Qt); | 3165 | specbind (Qinhibit_quit, Qt); |
| 3117 | specbind (Qlast_nonmenu_event, Qt); | 3166 | specbind (Qlast_nonmenu_event, Qt); |
| 3118 | call2 (sentinel, proc, reason); | 3167 | |
| 3168 | internal_condition_case_1 (read_process_output_call, | ||
| 3169 | Fcons (sentinel, | ||
| 3170 | Fcons (proc, Fcons (reason, Qnil))), | ||
| 3171 | !NILP (Vdebug_on_error) ? Qnil : Qerror, | ||
| 3172 | exec_sentinel_error_handler); | ||
| 3119 | 3173 | ||
| 3120 | Vdeactivate_mark = odeactivate; | 3174 | Vdeactivate_mark = odeactivate; |
| 3121 | if (! EQ (Fcurrent_buffer (), obuffer)) | 3175 | if (! EQ (Fcurrent_buffer (), obuffer)) |
| @@ -3322,6 +3376,7 @@ The value takes effect when `start-process' is called."); | |||
| 3322 | defsubr (&Sprocess_exit_status); | 3376 | defsubr (&Sprocess_exit_status); |
| 3323 | defsubr (&Sprocess_id); | 3377 | defsubr (&Sprocess_id); |
| 3324 | defsubr (&Sprocess_name); | 3378 | defsubr (&Sprocess_name); |
| 3379 | defsubr (&Sprocess_tty_name); | ||
| 3325 | defsubr (&Sprocess_command); | 3380 | defsubr (&Sprocess_command); |
| 3326 | defsubr (&Sset_process_buffer); | 3381 | defsubr (&Sset_process_buffer); |
| 3327 | defsubr (&Sprocess_buffer); | 3382 | defsubr (&Sprocess_buffer); |