diff options
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 85 |
1 files changed, 70 insertions, 15 deletions
diff --git a/src/process.c b/src/process.c index 3e2aa61ffe6..384a7acfccd 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -346,6 +346,9 @@ static int max_keyboard_desc; | |||
| 346 | /* The largest descriptor currently in use for gpm mouse input. */ | 346 | /* The largest descriptor currently in use for gpm mouse input. */ |
| 347 | static int max_gpm_desc; | 347 | static int max_gpm_desc; |
| 348 | 348 | ||
| 349 | /* Non-zero if keyboard input is on hold, zero otherwise. */ | ||
| 350 | static int kbd_is_on_hold; | ||
| 351 | |||
| 349 | /* Nonzero means delete a process right away if it exits. */ | 352 | /* Nonzero means delete a process right away if it exits. */ |
| 350 | static int delete_exited_processes; | 353 | static int delete_exited_processes; |
| 351 | 354 | ||
| @@ -3653,23 +3656,9 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3653 | immediate_quit = 1; | 3656 | immediate_quit = 1; |
| 3654 | QUIT; | 3657 | QUIT; |
| 3655 | 3658 | ||
| 3656 | /* This turns off all alarm-based interrupts; the | ||
| 3657 | bind_polling_period call above doesn't always turn all the | ||
| 3658 | short-interval ones off, especially if interrupt_input is | ||
| 3659 | set. | ||
| 3660 | |||
| 3661 | It'd be nice to be able to control the connect timeout | ||
| 3662 | though. Would non-blocking connect calls be portable? | ||
| 3663 | |||
| 3664 | This used to be conditioned by HAVE_GETADDRINFO. Why? */ | ||
| 3665 | |||
| 3666 | turn_on_atimers (0); | ||
| 3667 | |||
| 3668 | ret = connect (s, lres->ai_addr, lres->ai_addrlen); | 3659 | ret = connect (s, lres->ai_addr, lres->ai_addrlen); |
| 3669 | xerrno = errno; | 3660 | xerrno = errno; |
| 3670 | 3661 | ||
| 3671 | turn_on_atimers (1); | ||
| 3672 | |||
| 3673 | if (ret == 0 || xerrno == EISCONN) | 3662 | if (ret == 0 || xerrno == EISCONN) |
| 3674 | { | 3663 | { |
| 3675 | /* The unwind-protect will be discarded afterwards. | 3664 | /* The unwind-protect will be discarded afterwards. |
| @@ -3689,6 +3678,40 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3689 | #endif | 3678 | #endif |
| 3690 | #endif | 3679 | #endif |
| 3691 | 3680 | ||
| 3681 | #ifndef WINDOWSNT | ||
| 3682 | if (xerrno == EINTR) | ||
| 3683 | { | ||
| 3684 | /* Unlike most other syscalls connect() cannot be called | ||
| 3685 | again. (That would return EALREADY.) The proper way to | ||
| 3686 | wait for completion is select(). */ | ||
| 3687 | int sc, len; | ||
| 3688 | SELECT_TYPE fdset; | ||
| 3689 | retry_select: | ||
| 3690 | FD_ZERO (&fdset); | ||
| 3691 | FD_SET (s, &fdset); | ||
| 3692 | QUIT; | ||
| 3693 | sc = select (s + 1, (SELECT_TYPE *)0, &fdset, (SELECT_TYPE *)0, | ||
| 3694 | (EMACS_TIME *)0); | ||
| 3695 | if (sc == -1) | ||
| 3696 | { | ||
| 3697 | if (errno == EINTR) | ||
| 3698 | goto retry_select; | ||
| 3699 | else | ||
| 3700 | report_file_error ("select failed", Qnil); | ||
| 3701 | } | ||
| 3702 | eassert (sc > 0); | ||
| 3703 | |||
| 3704 | len = sizeof xerrno; | ||
| 3705 | eassert (FD_ISSET (s, &fdset)); | ||
| 3706 | if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) == -1) | ||
| 3707 | report_file_error ("getsockopt failed", Qnil); | ||
| 3708 | if (xerrno) | ||
| 3709 | errno = xerrno, report_file_error ("error during connect", Qnil); | ||
| 3710 | else | ||
| 3711 | break; | ||
| 3712 | } | ||
| 3713 | #endif /* !WINDOWSNT */ | ||
| 3714 | |||
| 3692 | immediate_quit = 0; | 3715 | immediate_quit = 0; |
| 3693 | 3716 | ||
| 3694 | /* Discard the unwind protect closing S. */ | 3717 | /* Discard the unwind protect closing S. */ |
| @@ -3696,8 +3719,10 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3696 | emacs_close (s); | 3719 | emacs_close (s); |
| 3697 | s = -1; | 3720 | s = -1; |
| 3698 | 3721 | ||
| 3722 | #ifdef WINDOWSNT | ||
| 3699 | if (xerrno == EINTR) | 3723 | if (xerrno == EINTR) |
| 3700 | goto retry_connect; | 3724 | goto retry_connect; |
| 3725 | #endif | ||
| 3701 | } | 3726 | } |
| 3702 | 3727 | ||
| 3703 | if (s >= 0) | 3728 | if (s >= 0) |
| @@ -4795,7 +4820,11 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 4795 | SELECT_TYPE Ctemp; | 4820 | SELECT_TYPE Ctemp; |
| 4796 | #endif | 4821 | #endif |
| 4797 | 4822 | ||
| 4798 | Atemp = input_wait_mask; | 4823 | if (kbd_on_hold_p ()) |
| 4824 | FD_ZERO (&Atemp); | ||
| 4825 | else | ||
| 4826 | Atemp = input_wait_mask; | ||
| 4827 | |||
| 4799 | IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); | 4828 | IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); |
| 4800 | 4829 | ||
| 4801 | EMACS_SET_SECS_USECS (timeout, 0, 0); | 4830 | EMACS_SET_SECS_USECS (timeout, 0, 0); |
| @@ -7224,6 +7253,31 @@ keyboard_bit_set (mask) | |||
| 7224 | 7253 | ||
| 7225 | return 0; | 7254 | return 0; |
| 7226 | } | 7255 | } |
| 7256 | |||
| 7257 | /* Stop reading input from keyboard sources. */ | ||
| 7258 | |||
| 7259 | void | ||
| 7260 | hold_keyboard_input (void) | ||
| 7261 | { | ||
| 7262 | kbd_is_on_hold = 1; | ||
| 7263 | } | ||
| 7264 | |||
| 7265 | /* Resume reading input from keyboard sources. */ | ||
| 7266 | |||
| 7267 | void | ||
| 7268 | unhold_keyboard_input (void) | ||
| 7269 | { | ||
| 7270 | kbd_is_on_hold = 0; | ||
| 7271 | } | ||
| 7272 | |||
| 7273 | /* Return non-zero if keyboard input is on hold, zero otherwise. */ | ||
| 7274 | |||
| 7275 | int | ||
| 7276 | kbd_on_hold_p (void) | ||
| 7277 | { | ||
| 7278 | return kbd_is_on_hold; | ||
| 7279 | } | ||
| 7280 | |||
| 7227 | 7281 | ||
| 7228 | /* Enumeration of and access to system processes a-la ps(1). */ | 7282 | /* Enumeration of and access to system processes a-la ps(1). */ |
| 7229 | 7283 | ||
| @@ -7302,6 +7356,7 @@ init_process () | |||
| 7302 | register int i; | 7356 | register int i; |
| 7303 | 7357 | ||
| 7304 | inhibit_sentinels = 0; | 7358 | inhibit_sentinels = 0; |
| 7359 | kbd_is_on_hold = 0; | ||
| 7305 | 7360 | ||
| 7306 | #ifdef SIGCHLD | 7361 | #ifdef SIGCHLD |
| 7307 | #ifndef CANNOT_DUMP | 7362 | #ifndef CANNOT_DUMP |