diff options
Diffstat (limited to 'src/sysdep.c')
| -rw-r--r-- | src/sysdep.c | 117 |
1 files changed, 23 insertions, 94 deletions
diff --git a/src/sysdep.c b/src/sysdep.c index 0f16d1a7645..dbfd9efc7d4 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -23,7 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 23 | 23 | ||
| 24 | #include <execinfo.h> | 24 | #include <execinfo.h> |
| 25 | #include <stdio.h> | 25 | #include <stdio.h> |
| 26 | #include <setjmp.h> | ||
| 27 | #ifdef HAVE_PWD_H | 26 | #ifdef HAVE_PWD_H |
| 28 | #include <pwd.h> | 27 | #include <pwd.h> |
| 29 | #include <grp.h> | 28 | #include <grp.h> |
| @@ -107,9 +106,6 @@ extern char *getwd (char *); | |||
| 107 | 106 | ||
| 108 | static int emacs_get_tty (int, struct emacs_tty *); | 107 | static int emacs_get_tty (int, struct emacs_tty *); |
| 109 | static int emacs_set_tty (int, struct emacs_tty *, int); | 108 | static int emacs_set_tty (int, struct emacs_tty *, int); |
| 110 | #if defined TIOCNOTTY || defined USG5 || defined CYGWIN | ||
| 111 | static _Noreturn void croak (char *); | ||
| 112 | #endif | ||
| 113 | 109 | ||
| 114 | /* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */ | 110 | /* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */ |
| 115 | #ifndef ULLONG_MAX | 111 | #ifndef ULLONG_MAX |
| @@ -513,7 +509,7 @@ sys_subshell (void) | |||
| 513 | saved_handlers[0].code = SIGINT; | 509 | saved_handlers[0].code = SIGINT; |
| 514 | saved_handlers[1].code = SIGQUIT; | 510 | saved_handlers[1].code = SIGQUIT; |
| 515 | saved_handlers[2].code = SIGTERM; | 511 | saved_handlers[2].code = SIGTERM; |
| 516 | #ifdef SIGIO | 512 | #ifdef USABLE_SIGIO |
| 517 | saved_handlers[3].code = SIGIO; | 513 | saved_handlers[3].code = SIGIO; |
| 518 | saved_handlers[4].code = 0; | 514 | saved_handlers[4].code = 0; |
| 519 | #else | 515 | #else |
| @@ -642,121 +638,75 @@ restore_signal_handlers (struct save_signal *saved_handlers) | |||
| 642 | } | 638 | } |
| 643 | } | 639 | } |
| 644 | 640 | ||
| 645 | #ifndef SIGIO | 641 | #ifdef USABLE_SIGIO |
| 646 | /* If SIGIO is broken, don't do anything. */ | ||
| 647 | void | ||
| 648 | init_sigio (int fd) | ||
| 649 | { | ||
| 650 | } | ||
| 651 | |||
| 652 | static void | ||
| 653 | reset_sigio (int fd) | ||
| 654 | { | ||
| 655 | } | ||
| 656 | |||
| 657 | void | ||
| 658 | request_sigio (void) | ||
| 659 | { | ||
| 660 | } | ||
| 661 | |||
| 662 | void | ||
| 663 | unrequest_sigio (void) | ||
| 664 | { | ||
| 665 | } | ||
| 666 | |||
| 667 | #else | ||
| 668 | #ifdef F_SETFL | ||
| 669 | |||
| 670 | static int old_fcntl_flags[MAXDESC]; | 642 | static int old_fcntl_flags[MAXDESC]; |
| 643 | #endif | ||
| 671 | 644 | ||
| 672 | void | 645 | void |
| 673 | init_sigio (int fd) | 646 | init_sigio (int fd) |
| 674 | { | 647 | { |
| 675 | #ifdef FASYNC | 648 | #ifdef USABLE_SIGIO |
| 676 | old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC; | 649 | old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC; |
| 677 | fcntl (fd, F_SETFL, old_fcntl_flags[fd] | FASYNC); | 650 | fcntl (fd, F_SETFL, old_fcntl_flags[fd] | FASYNC); |
| 678 | #endif | ||
| 679 | interrupts_deferred = 0; | 651 | interrupts_deferred = 0; |
| 652 | #endif | ||
| 680 | } | 653 | } |
| 681 | 654 | ||
| 682 | static void | 655 | static void |
| 683 | reset_sigio (int fd) | 656 | reset_sigio (int fd) |
| 684 | { | 657 | { |
| 685 | #ifdef FASYNC | 658 | #ifdef USABLE_SIGIO |
| 686 | fcntl (fd, F_SETFL, old_fcntl_flags[fd]); | 659 | fcntl (fd, F_SETFL, old_fcntl_flags[fd]); |
| 687 | #endif | 660 | #endif |
| 688 | } | 661 | } |
| 689 | 662 | ||
| 690 | #ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */ | ||
| 691 | /* XXX Uhm, FASYNC is not used anymore here. */ | ||
| 692 | /* XXX Yeah, but you need it for SIGIO, don't you? */ | ||
| 693 | |||
| 694 | void | 663 | void |
| 695 | request_sigio (void) | 664 | request_sigio (void) |
| 696 | { | 665 | { |
| 666 | #ifdef USABLE_SIGIO | ||
| 697 | sigset_t unblocked; | 667 | sigset_t unblocked; |
| 698 | 668 | ||
| 699 | if (noninteractive) | 669 | if (noninteractive) |
| 700 | return; | 670 | return; |
| 701 | 671 | ||
| 702 | sigemptyset (&unblocked); | 672 | sigemptyset (&unblocked); |
| 703 | #ifdef SIGWINCH | 673 | # ifdef SIGWINCH |
| 704 | sigaddset (&unblocked, SIGWINCH); | 674 | sigaddset (&unblocked, SIGWINCH); |
| 705 | #endif | 675 | # endif |
| 706 | sigaddset (&unblocked, SIGIO); | 676 | sigaddset (&unblocked, SIGIO); |
| 707 | pthread_sigmask (SIG_UNBLOCK, &unblocked, 0); | 677 | pthread_sigmask (SIG_UNBLOCK, &unblocked, 0); |
| 708 | 678 | ||
| 709 | interrupts_deferred = 0; | 679 | interrupts_deferred = 0; |
| 680 | #endif | ||
| 710 | } | 681 | } |
| 711 | 682 | ||
| 712 | void | 683 | void |
| 713 | unrequest_sigio (void) | 684 | unrequest_sigio (void) |
| 714 | { | 685 | { |
| 686 | #ifdef USABLE_SIGIO | ||
| 715 | sigset_t blocked; | 687 | sigset_t blocked; |
| 716 | 688 | ||
| 717 | if (noninteractive) | 689 | if (noninteractive) |
| 718 | return; | 690 | return; |
| 719 | 691 | ||
| 720 | #if 0 /* XXX What's wrong with blocking SIGIO under X? */ | ||
| 721 | if (x_display_list) | ||
| 722 | return; | ||
| 723 | #endif | ||
| 724 | |||
| 725 | sigemptyset (&blocked); | 692 | sigemptyset (&blocked); |
| 726 | #ifdef SIGWINCH | 693 | # ifdef SIGWINCH |
| 727 | sigaddset (&blocked, SIGWINCH); | 694 | sigaddset (&blocked, SIGWINCH); |
| 728 | #endif | 695 | # endif |
| 729 | sigaddset (&blocked, SIGIO); | 696 | sigaddset (&blocked, SIGIO); |
| 730 | pthread_sigmask (SIG_BLOCK, &blocked, 0); | 697 | pthread_sigmask (SIG_BLOCK, &blocked, 0); |
| 731 | interrupts_deferred = 1; | 698 | interrupts_deferred = 1; |
| 732 | } | 699 | #endif |
| 733 | |||
| 734 | #else /* no FASYNC */ | ||
| 735 | #ifndef MSDOS | ||
| 736 | |||
| 737 | void | ||
| 738 | request_sigio (void) | ||
| 739 | { | ||
| 740 | if (noninteractive || read_socket_hook) | ||
| 741 | return; | ||
| 742 | |||
| 743 | croak ("request_sigio"); | ||
| 744 | } | 700 | } |
| 745 | 701 | ||
| 746 | void | 702 | void |
| 747 | unrequest_sigio (void) | 703 | ignore_sigio (void) |
| 748 | { | 704 | { |
| 749 | if (noninteractive || read_socket_hook) | 705 | #ifdef USABLE_SIGIO |
| 750 | return; | 706 | signal (SIGIO, SIG_IGN); |
| 751 | 707 | #endif | |
| 752 | croak ("unrequest_sigio"); | ||
| 753 | } | 708 | } |
| 754 | 709 | ||
| 755 | #endif /* MSDOS */ | ||
| 756 | #endif /* FASYNC */ | ||
| 757 | #endif /* F_SETFL */ | ||
| 758 | #endif /* SIGIO */ | ||
| 759 | |||
| 760 | 710 | ||
| 761 | /* Getting and setting emacs_tty structures. */ | 711 | /* Getting and setting emacs_tty structures. */ |
| 762 | 712 | ||
| @@ -1497,27 +1447,21 @@ emacs_sigaction_init (struct sigaction *action, signal_handler_t handler) | |||
| 1497 | action->sa_handler = handler; | 1447 | action->sa_handler = handler; |
| 1498 | action->sa_flags = 0; | 1448 | action->sa_flags = 0; |
| 1499 | #if defined (SA_RESTART) | 1449 | #if defined (SA_RESTART) |
| 1500 | /* Emacs mostly works better with restartable system services. If this | 1450 | /* SA_RESTART causes interruptible functions with timeouts (e.g., |
| 1501 | flag exists, we probably want to turn it on here. | 1451 | 'select') to reset their timeout on some platforms (e.g., |
| 1502 | However, on some systems (only hpux11 at present) this resets the | 1452 | HP-UX 11), which is not what we want. Also, when Emacs is |
| 1503 | timeout of `select' which means that `select' never finishes if | 1453 | interactive, we don't want SA_RESTART because we need to poll |
| 1504 | it keeps getting signals. | ||
| 1505 | We define BROKEN_SA_RESTART on those systems. */ | ||
| 1506 | /* It's not clear why the comment above says "mostly works better". --Stef | ||
| 1507 | When SYNC_INPUT is set, we don't want SA_RESTART because we need to poll | ||
| 1508 | for pending input so we need long-running syscalls to be interrupted | 1454 | for pending input so we need long-running syscalls to be interrupted |
| 1509 | after a signal that sets the interrupt_input_pending flag. */ | 1455 | after a signal that sets the interrupt_input_pending flag. */ |
| 1510 | /* Non-interactive keyboard input goes through stdio, where we always | 1456 | /* Non-interactive keyboard input goes through stdio, where we always |
| 1511 | want restartable system calls. */ | 1457 | want restartable system calls. */ |
| 1512 | # if defined (BROKEN_SA_RESTART) || defined (SYNC_INPUT) | ||
| 1513 | if (noninteractive) | 1458 | if (noninteractive) |
| 1514 | # endif | ||
| 1515 | action->sa_flags = SA_RESTART; | 1459 | action->sa_flags = SA_RESTART; |
| 1516 | #endif | 1460 | #endif |
| 1517 | } | 1461 | } |
| 1518 | 1462 | ||
| 1519 | #ifdef FORWARD_SIGNAL_TO_MAIN_THREAD | 1463 | #ifdef FORWARD_SIGNAL_TO_MAIN_THREAD |
| 1520 | pthread_t main_thread; | 1464 | static pthread_t main_thread; |
| 1521 | #endif | 1465 | #endif |
| 1522 | 1466 | ||
| 1523 | /* If we are on the main thread, handle the signal SIG with HANDLER. | 1467 | /* If we are on the main thread, handle the signal SIG with HANDLER. |
| @@ -1964,11 +1908,9 @@ emacs_write (int fildes, const char *buf, ptrdiff_t nbyte) | |||
| 1964 | { | 1908 | { |
| 1965 | if (errno == EINTR) | 1909 | if (errno == EINTR) |
| 1966 | { | 1910 | { |
| 1967 | #ifdef SYNC_INPUT | ||
| 1968 | /* I originally used `QUIT' but that might causes files to | 1911 | /* I originally used `QUIT' but that might causes files to |
| 1969 | be truncated if you hit C-g in the middle of it. --Stef */ | 1912 | be truncated if you hit C-g in the middle of it. --Stef */ |
| 1970 | process_pending_signals (); | 1913 | process_pending_signals (); |
| 1971 | #endif | ||
| 1972 | continue; | 1914 | continue; |
| 1973 | } | 1915 | } |
| 1974 | else | 1916 | else |
| @@ -2051,19 +1993,6 @@ getwd (char *pathname) | |||
| 2051 | } | 1993 | } |
| 2052 | 1994 | ||
| 2053 | #endif /* !defined (HAVE_GETWD) || defined (BROKEN_GETWD) */ | 1995 | #endif /* !defined (HAVE_GETWD) || defined (BROKEN_GETWD) */ |
| 2054 | |||
| 2055 | /* | ||
| 2056 | * This function will go away as soon as all the stubs fixed. (fnf) | ||
| 2057 | */ | ||
| 2058 | |||
| 2059 | void | ||
| 2060 | croak (char *badfunc) | ||
| 2061 | { | ||
| 2062 | printf ("%s not yet implemented\r\n", badfunc); | ||
| 2063 | reset_all_sys_modes (); | ||
| 2064 | exit (1); | ||
| 2065 | } | ||
| 2066 | |||
| 2067 | #endif /* USG */ | 1996 | #endif /* USG */ |
| 2068 | 1997 | ||
| 2069 | /* Directory routines for systems that don't have them. */ | 1998 | /* Directory routines for systems that don't have them. */ |