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 3879821c2fa..f23b8368f6d 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 | { |
| @@ -767,23 +771,27 @@ nil, indicating the current buffer's process. */) | |||
| 767 | (process) | 771 | (process) |
| 768 | register Lisp_Object process; | 772 | register Lisp_Object process; |
| 769 | { | 773 | { |
| 774 | register struct Lisp_Process *p; | ||
| 775 | |||
| 770 | process = get_process (process); | 776 | process = get_process (process); |
| 771 | XPROCESS (process)->raw_status_low = Qnil; | 777 | p = XPROCESS (process); |
| 772 | XPROCESS (process)->raw_status_high = Qnil; | 778 | |
| 773 | if (NETCONN_P (process)) | 779 | p->raw_status_low = Qnil; |
| 780 | p->raw_status_high = Qnil; | ||
| 781 | if (NETCONN1_P (p)) | ||
| 774 | { | 782 | { |
| 775 | XPROCESS (process)->status = Fcons (Qexit, Fcons (make_number (0), Qnil)); | 783 | p->status = Fcons (Qexit, Fcons (make_number (0), Qnil)); |
| 776 | XSETINT (XPROCESS (process)->tick, ++process_tick); | 784 | XSETINT (p->tick, ++process_tick); |
| 777 | status_notify (); | 785 | status_notify (p); |
| 778 | } | 786 | } |
| 779 | else if (XINT (XPROCESS (process)->infd) >= 0) | 787 | else if (XINT (p->infd) >= 0) |
| 780 | { | 788 | { |
| 781 | Fkill_process (process, Qnil); | 789 | Fkill_process (process, Qnil); |
| 782 | /* Do this now, since remove_process will make sigchld_handler do nothing. */ | 790 | /* Do this now, since remove_process will make sigchld_handler do nothing. */ |
| 783 | XPROCESS (process)->status | 791 | p->status |
| 784 | = Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil)); | 792 | = Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil)); |
| 785 | XSETINT (XPROCESS (process)->tick, ++process_tick); | 793 | XSETINT (p->tick, ++process_tick); |
| 786 | status_notify (); | 794 | status_notify (p); |
| 787 | } | 795 | } |
| 788 | remove_process (process); | 796 | remove_process (process); |
| 789 | return Qnil; | 797 | return Qnil; |
| @@ -1237,7 +1245,7 @@ IP address. Returns nil if format of ADDRESS is invalid. */) | |||
| 1237 | } | 1245 | } |
| 1238 | #endif | 1246 | #endif |
| 1239 | 1247 | ||
| 1240 | Lisp_Object | 1248 | static Lisp_Object |
| 1241 | list_processes_1 (query_only) | 1249 | list_processes_1 (query_only) |
| 1242 | Lisp_Object query_only; | 1250 | Lisp_Object query_only; |
| 1243 | { | 1251 | { |
| @@ -1707,7 +1715,7 @@ start_process_unwind (proc) | |||
| 1707 | return Qnil; | 1715 | return Qnil; |
| 1708 | } | 1716 | } |
| 1709 | 1717 | ||
| 1710 | void | 1718 | static void |
| 1711 | create_process_1 (timer) | 1719 | create_process_1 (timer) |
| 1712 | struct atimer *timer; | 1720 | struct atimer *timer; |
| 1713 | { | 1721 | { |
| @@ -2530,7 +2538,7 @@ OPTION is not a supported option, return nil instead; otherwise return t. */) | |||
| 2530 | 2538 | ||
| 2531 | /* A version of request_sigio suitable for a record_unwind_protect. */ | 2539 | /* A version of request_sigio suitable for a record_unwind_protect. */ |
| 2532 | 2540 | ||
| 2533 | Lisp_Object | 2541 | static Lisp_Object |
| 2534 | unwind_request_sigio (dummy) | 2542 | unwind_request_sigio (dummy) |
| 2535 | Lisp_Object dummy; | 2543 | Lisp_Object dummy; |
| 2536 | { | 2544 | { |
| @@ -4221,7 +4229,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 4221 | /* It's okay for us to do this and then continue with | 4229 | /* It's okay for us to do this and then continue with |
| 4222 | the loop, since timeout has already been zeroed out. */ | 4230 | the loop, since timeout has already been zeroed out. */ |
| 4223 | clear_waiting_for_input (); | 4231 | clear_waiting_for_input (); |
| 4224 | status_notify (); | 4232 | status_notify (NULL); |
| 4225 | } | 4233 | } |
| 4226 | } | 4234 | } |
| 4227 | 4235 | ||
| @@ -4739,7 +4747,7 @@ read_process_output_error_handler (error) | |||
| 4739 | The characters read are decoded according to PROC's coding-system | 4747 | The characters read are decoded according to PROC's coding-system |
| 4740 | for decoding. */ | 4748 | for decoding. */ |
| 4741 | 4749 | ||
| 4742 | int | 4750 | static int |
| 4743 | read_process_output (proc, channel) | 4751 | read_process_output (proc, channel) |
| 4744 | Lisp_Object proc; | 4752 | Lisp_Object proc; |
| 4745 | register int channel; | 4753 | register int channel; |
| @@ -5130,7 +5138,7 @@ send_process_trap () | |||
| 5130 | 5138 | ||
| 5131 | This function can evaluate Lisp code and can garbage collect. */ | 5139 | This function can evaluate Lisp code and can garbage collect. */ |
| 5132 | 5140 | ||
| 5133 | void | 5141 | static void |
| 5134 | send_process (proc, buf, len, object) | 5142 | send_process (proc, buf, len, object) |
| 5135 | volatile Lisp_Object proc; | 5143 | volatile Lisp_Object proc; |
| 5136 | unsigned char *volatile buf; | 5144 | unsigned char *volatile buf; |
| @@ -5724,7 +5732,7 @@ process_send_signal (process, signo, current_group, nomsg) | |||
| 5724 | p->status = Qrun; | 5732 | p->status = Qrun; |
| 5725 | XSETINT (p->tick, ++process_tick); | 5733 | XSETINT (p->tick, ++process_tick); |
| 5726 | if (!nomsg) | 5734 | if (!nomsg) |
| 5727 | status_notify (); | 5735 | status_notify (NULL); |
| 5728 | break; | 5736 | break; |
| 5729 | #endif /* ! defined (SIGCONT) */ | 5737 | #endif /* ! defined (SIGCONT) */ |
| 5730 | case SIGINT: | 5738 | case SIGINT: |
| @@ -6392,8 +6400,9 @@ exec_sentinel (proc, reason) | |||
| 6392 | This is usually done while Emacs is waiting for keyboard input | 6400 | This is usually done while Emacs is waiting for keyboard input |
| 6393 | but can be done at other times. */ | 6401 | but can be done at other times. */ |
| 6394 | 6402 | ||
| 6395 | void | 6403 | static void |
| 6396 | status_notify () | 6404 | status_notify (deleting_process) |
| 6405 | struct Lisp_Process *deleting_process; | ||
| 6397 | { | 6406 | { |
| 6398 | register Lisp_Object proc, buffer; | 6407 | register Lisp_Object proc, buffer; |
| 6399 | Lisp_Object tail, msg; | 6408 | Lisp_Object tail, msg; |
| @@ -6429,6 +6438,7 @@ status_notify () | |||
| 6429 | && ! EQ (p->status, Qlisten) | 6438 | && ! EQ (p->status, Qlisten) |
| 6430 | && ! EQ (p->command, Qt) /* Network process not stopped. */ | 6439 | && ! EQ (p->command, Qt) /* Network process not stopped. */ |
| 6431 | && XINT (p->infd) >= 0 | 6440 | && XINT (p->infd) >= 0 |
| 6441 | && p != deleting_process | ||
| 6432 | && read_process_output (proc, XINT (p->infd)) > 0); | 6442 | && read_process_output (proc, XINT (p->infd)) > 0); |
| 6433 | 6443 | ||
| 6434 | buffer = p->buffer; | 6444 | buffer = p->buffer; |
| @@ -6624,7 +6634,7 @@ delete_keyboard_wait_descriptor (desc) | |||
| 6624 | /* Return nonzero if *MASK has a bit set | 6634 | /* Return nonzero if *MASK has a bit set |
| 6625 | that corresponds to one of the keyboard input descriptors. */ | 6635 | that corresponds to one of the keyboard input descriptors. */ |
| 6626 | 6636 | ||
| 6627 | int | 6637 | static int |
| 6628 | keyboard_bit_set (mask) | 6638 | keyboard_bit_set (mask) |
| 6629 | SELECT_TYPE *mask; | 6639 | SELECT_TYPE *mask; |
| 6630 | { | 6640 | { |