diff options
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 70 |
1 files changed, 40 insertions, 30 deletions
diff --git a/src/process.c b/src/process.c index 1890a2a0893..a7ef9c36589 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | /* Asynchronous subprocess control for GNU Emacs. | 1 | /* Asynchronous subprocess control for GNU Emacs. |
| 2 | Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1996, 1998, 1999, | 2 | Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, |
| 3 | 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. | 3 | 1996, 1998, 1999, 2001, 2002, 2003, 2004, |
| 4 | 2005 Free Software Foundation, Inc. | ||
| 4 | 5 | ||
| 5 | This file is part of GNU Emacs. | 6 | This file is part of GNU Emacs. |
| 6 | 7 | ||
| @@ -293,7 +294,10 @@ static Lisp_Object Vprocess_adaptive_read_buffering; | |||
| 293 | 294 | ||
| 294 | #include "sysselect.h" | 295 | #include "sysselect.h" |
| 295 | 296 | ||
| 296 | extern int keyboard_bit_set P_ ((SELECT_TYPE *)); | 297 | static int keyboard_bit_set P_ ((SELECT_TYPE *)); |
| 298 | static void deactivate_process P_ ((Lisp_Object)); | ||
| 299 | static void status_notify P_ ((struct Lisp_Process *)); | ||
| 300 | static int read_process_output P_ ((Lisp_Object, int)); | ||
| 297 | 301 | ||
| 298 | /* If we support a window system, turn on the code to poll periodically | 302 | /* If we support a window system, turn on the code to poll periodically |
| 299 | to detect C-g. It isn't actually used when doing interrupt input. */ | 303 | to detect C-g. It isn't actually used when doing interrupt input. */ |
| @@ -390,9 +394,9 @@ static char pty_name[24]; | |||
| 390 | /* Compute the Lisp form of the process status, p->status, from | 394 | /* Compute the Lisp form of the process status, p->status, from |
| 391 | the numeric status that was returned by `wait'. */ | 395 | the numeric status that was returned by `wait'. */ |
| 392 | 396 | ||
| 393 | Lisp_Object status_convert (); | 397 | static Lisp_Object status_convert (); |
| 394 | 398 | ||
| 395 | void | 399 | static void |
| 396 | update_status (p) | 400 | update_status (p) |
| 397 | struct Lisp_Process *p; | 401 | struct Lisp_Process *p; |
| 398 | { | 402 | { |
| @@ -406,7 +410,7 @@ update_status (p) | |||
| 406 | /* Convert a process status word in Unix format to | 410 | /* Convert a process status word in Unix format to |
| 407 | the list that we use internally. */ | 411 | the list that we use internally. */ |
| 408 | 412 | ||
| 409 | Lisp_Object | 413 | static Lisp_Object |
| 410 | status_convert (w) | 414 | status_convert (w) |
| 411 | WAITTYPE w; | 415 | WAITTYPE w; |
| 412 | { | 416 | { |
| @@ -425,7 +429,7 @@ status_convert (w) | |||
| 425 | /* Given a status-list, extract the three pieces of information | 429 | /* Given a status-list, extract the three pieces of information |
| 426 | and store them individually through the three pointers. */ | 430 | and store them individually through the three pointers. */ |
| 427 | 431 | ||
| 428 | void | 432 | static void |
| 429 | decode_status (l, symbol, code, coredump) | 433 | decode_status (l, symbol, code, coredump) |
| 430 | Lisp_Object l; | 434 | Lisp_Object l; |
| 431 | Lisp_Object *symbol; | 435 | Lisp_Object *symbol; |
| @@ -504,7 +508,7 @@ status_message (p) | |||
| 504 | The file name of the terminal corresponding to the pty | 508 | The file name of the terminal corresponding to the pty |
| 505 | is left in the variable pty_name. */ | 509 | is left in the variable pty_name. */ |
| 506 | 510 | ||
| 507 | int | 511 | static int |
| 508 | allocate_pty () | 512 | allocate_pty () |
| 509 | { | 513 | { |
| 510 | register int c, i; | 514 | register int c, i; |
| @@ -589,7 +593,7 @@ allocate_pty () | |||
| 589 | } | 593 | } |
| 590 | #endif /* HAVE_PTYS */ | 594 | #endif /* HAVE_PTYS */ |
| 591 | 595 | ||
| 592 | Lisp_Object | 596 | static Lisp_Object |
| 593 | make_process (name) | 597 | make_process (name) |
| 594 | Lisp_Object name; | 598 | Lisp_Object name; |
| 595 | { | 599 | { |
| @@ -633,7 +637,7 @@ make_process (name) | |||
| 633 | return val; | 637 | return val; |
| 634 | } | 638 | } |
| 635 | 639 | ||
| 636 | void | 640 | static void |
| 637 | remove_process (proc) | 641 | remove_process (proc) |
| 638 | register Lisp_Object proc; | 642 | register Lisp_Object proc; |
| 639 | { | 643 | { |
| @@ -768,23 +772,27 @@ nil, indicating the current buffer's process. */) | |||
| 768 | (process) | 772 | (process) |
| 769 | register Lisp_Object process; | 773 | register Lisp_Object process; |
| 770 | { | 774 | { |
| 775 | register struct Lisp_Process *p; | ||
| 776 | |||
| 771 | process = get_process (process); | 777 | process = get_process (process); |
| 772 | XPROCESS (process)->raw_status_low = Qnil; | 778 | p = XPROCESS (process); |
| 773 | XPROCESS (process)->raw_status_high = Qnil; | 779 | |
| 774 | if (NETCONN_P (process)) | 780 | p->raw_status_low = Qnil; |
| 781 | p->raw_status_high = Qnil; | ||
| 782 | if (NETCONN1_P (p)) | ||
| 775 | { | 783 | { |
| 776 | XPROCESS (process)->status = Fcons (Qexit, Fcons (make_number (0), Qnil)); | 784 | p->status = Fcons (Qexit, Fcons (make_number (0), Qnil)); |
| 777 | XSETINT (XPROCESS (process)->tick, ++process_tick); | 785 | XSETINT (p->tick, ++process_tick); |
| 778 | status_notify (); | 786 | status_notify (p); |
| 779 | } | 787 | } |
| 780 | else if (XINT (XPROCESS (process)->infd) >= 0) | 788 | else if (XINT (p->infd) >= 0) |
| 781 | { | 789 | { |
| 782 | Fkill_process (process, Qnil); | 790 | Fkill_process (process, Qnil); |
| 783 | /* Do this now, since remove_process will make sigchld_handler do nothing. */ | 791 | /* Do this now, since remove_process will make sigchld_handler do nothing. */ |
| 784 | XPROCESS (process)->status | 792 | p->status |
| 785 | = Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil)); | 793 | = Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil)); |
| 786 | XSETINT (XPROCESS (process)->tick, ++process_tick); | 794 | XSETINT (p->tick, ++process_tick); |
| 787 | status_notify (); | 795 | status_notify (p); |
| 788 | } | 796 | } |
| 789 | remove_process (process); | 797 | remove_process (process); |
| 790 | return Qnil; | 798 | return Qnil; |
| @@ -1238,7 +1246,7 @@ IP address. Returns nil if format of ADDRESS is invalid. */) | |||
| 1238 | } | 1246 | } |
| 1239 | #endif | 1247 | #endif |
| 1240 | 1248 | ||
| 1241 | Lisp_Object | 1249 | static Lisp_Object |
| 1242 | list_processes_1 (query_only) | 1250 | list_processes_1 (query_only) |
| 1243 | Lisp_Object query_only; | 1251 | Lisp_Object query_only; |
| 1244 | { | 1252 | { |
| @@ -1708,7 +1716,7 @@ start_process_unwind (proc) | |||
| 1708 | return Qnil; | 1716 | return Qnil; |
| 1709 | } | 1717 | } |
| 1710 | 1718 | ||
| 1711 | void | 1719 | static void |
| 1712 | create_process_1 (timer) | 1720 | create_process_1 (timer) |
| 1713 | struct atimer *timer; | 1721 | struct atimer *timer; |
| 1714 | { | 1722 | { |
| @@ -2531,7 +2539,7 @@ OPTION is not a supported option, return nil instead; otherwise return t. */) | |||
| 2531 | 2539 | ||
| 2532 | /* A version of request_sigio suitable for a record_unwind_protect. */ | 2540 | /* A version of request_sigio suitable for a record_unwind_protect. */ |
| 2533 | 2541 | ||
| 2534 | Lisp_Object | 2542 | static Lisp_Object |
| 2535 | unwind_request_sigio (dummy) | 2543 | unwind_request_sigio (dummy) |
| 2536 | Lisp_Object dummy; | 2544 | Lisp_Object dummy; |
| 2537 | { | 2545 | { |
| @@ -4222,7 +4230,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 4222 | /* It's okay for us to do this and then continue with | 4230 | /* It's okay for us to do this and then continue with |
| 4223 | the loop, since timeout has already been zeroed out. */ | 4231 | the loop, since timeout has already been zeroed out. */ |
| 4224 | clear_waiting_for_input (); | 4232 | clear_waiting_for_input (); |
| 4225 | status_notify (); | 4233 | status_notify (NULL); |
| 4226 | } | 4234 | } |
| 4227 | } | 4235 | } |
| 4228 | 4236 | ||
| @@ -4740,7 +4748,7 @@ read_process_output_error_handler (error) | |||
| 4740 | The characters read are decoded according to PROC's coding-system | 4748 | The characters read are decoded according to PROC's coding-system |
| 4741 | for decoding. */ | 4749 | for decoding. */ |
| 4742 | 4750 | ||
| 4743 | int | 4751 | static int |
| 4744 | read_process_output (proc, channel) | 4752 | read_process_output (proc, channel) |
| 4745 | Lisp_Object proc; | 4753 | Lisp_Object proc; |
| 4746 | register int channel; | 4754 | register int channel; |
| @@ -5135,7 +5143,7 @@ send_process_trap () | |||
| 5135 | 5143 | ||
| 5136 | This function can evaluate Lisp code and can garbage collect. */ | 5144 | This function can evaluate Lisp code and can garbage collect. */ |
| 5137 | 5145 | ||
| 5138 | void | 5146 | static void |
| 5139 | send_process (proc, buf, len, object) | 5147 | send_process (proc, buf, len, object) |
| 5140 | volatile Lisp_Object proc; | 5148 | volatile Lisp_Object proc; |
| 5141 | unsigned char *volatile buf; | 5149 | unsigned char *volatile buf; |
| @@ -5722,7 +5730,7 @@ process_send_signal (process, signo, current_group, nomsg) | |||
| 5722 | p->status = Qrun; | 5730 | p->status = Qrun; |
| 5723 | XSETINT (p->tick, ++process_tick); | 5731 | XSETINT (p->tick, ++process_tick); |
| 5724 | if (!nomsg) | 5732 | if (!nomsg) |
| 5725 | status_notify (); | 5733 | status_notify (NULL); |
| 5726 | break; | 5734 | break; |
| 5727 | #endif /* ! defined (SIGCONT) */ | 5735 | #endif /* ! defined (SIGCONT) */ |
| 5728 | case SIGINT: | 5736 | case SIGINT: |
| @@ -6390,8 +6398,9 @@ exec_sentinel (proc, reason) | |||
| 6390 | This is usually done while Emacs is waiting for keyboard input | 6398 | This is usually done while Emacs is waiting for keyboard input |
| 6391 | but can be done at other times. */ | 6399 | but can be done at other times. */ |
| 6392 | 6400 | ||
| 6393 | void | 6401 | static void |
| 6394 | status_notify () | 6402 | status_notify (deleting_process) |
| 6403 | struct Lisp_Process *deleting_process; | ||
| 6395 | { | 6404 | { |
| 6396 | register Lisp_Object proc, buffer; | 6405 | register Lisp_Object proc, buffer; |
| 6397 | Lisp_Object tail, msg; | 6406 | Lisp_Object tail, msg; |
| @@ -6427,6 +6436,7 @@ status_notify () | |||
| 6427 | && ! EQ (p->status, Qlisten) | 6436 | && ! EQ (p->status, Qlisten) |
| 6428 | && ! EQ (p->command, Qt) /* Network process not stopped. */ | 6437 | && ! EQ (p->command, Qt) /* Network process not stopped. */ |
| 6429 | && XINT (p->infd) >= 0 | 6438 | && XINT (p->infd) >= 0 |
| 6439 | && p != deleting_process | ||
| 6430 | && read_process_output (proc, XINT (p->infd)) > 0); | 6440 | && read_process_output (proc, XINT (p->infd)) > 0); |
| 6431 | 6441 | ||
| 6432 | buffer = p->buffer; | 6442 | buffer = p->buffer; |
| @@ -6630,7 +6640,7 @@ delete_keyboard_wait_descriptor (desc) | |||
| 6630 | /* Return nonzero if *MASK has a bit set | 6640 | /* Return nonzero if *MASK has a bit set |
| 6631 | that corresponds to one of the keyboard input descriptors. */ | 6641 | that corresponds to one of the keyboard input descriptors. */ |
| 6632 | 6642 | ||
| 6633 | int | 6643 | static int |
| 6634 | keyboard_bit_set (mask) | 6644 | keyboard_bit_set (mask) |
| 6635 | SELECT_TYPE *mask; | 6645 | SELECT_TYPE *mask; |
| 6636 | { | 6646 | { |