diff options
| author | Paul Eggert | 2012-11-17 14:12:47 -0800 |
|---|---|---|
| committer | Paul Eggert | 2012-11-17 14:12:47 -0800 |
| commit | 49cdacdad393e2b9282a19a963030dfbe1a738ab (patch) | |
| tree | 40b11ac721a6a64102dae1a4f227fbc4d1eff0bc /src/term.c | |
| parent | 310e60d9454fe2d7e6920cf51f20d438e57f7b28 (diff) | |
| download | emacs-49cdacdad393e2b9282a19a963030dfbe1a738ab.tar.gz emacs-49cdacdad393e2b9282a19a963030dfbe1a738ab.zip | |
Assume POSIX 1003.1-1988 or later for fcntl.h.
* admin/CPP-DEFINES (O_RDONLY, O_RDWR, HAVE_FCNTL_H): Remove.
* admin/merge-gnulib (GNULIB_MODULES): Add fcntl-h.
* configure.ac: Do not check for fcntl.h.
* lib/gnulib.mk: Regenerate.
* lib-src/movemail.c, lib-src/update-game-score.c: Assume <fcntl.h> exists.
* nt/inc/sys/socket.h (O_NONBLOCK): Rename from O_NDELAY, since the
POSIX name for this flag is O_NONBLOCK. All uses changed.
* nt/inc/unistd.h (O_RDWR, O_NOCTTY): New macros. Like AT_FDCWD etc.
these really should be moved to a replacement <fcntl.h> if and
when that gets implemented. In the meantime, include <fcntl.h>
to make sure we don't override its definitions.
* src/callproc.c (relocate_fd): Assume F_DUPFD.
* src/emacs.c, src/term.c (O_RDWR): Remove.
* src/keyboard.c (tty_read_avail_input): Use O_NONBLOCK rather than
O_NDELAY, since O_NONBLOCK is the standard name for this flag.
* src/nsterm.m: Assume <fcntl.h> exists.
* src/process.c (NON_BLOCKING_CONNECT, allocate_pty, create_process)
(create_pty, Fmake_network_process, server_accept_connection)
(wait_reading_process_output, init_process_emacs):
Assume O_NONBLOCK.
(wait_reading_process_output): Put in a special case for WINDOWSNT
to mimick the older behavior where it had O_NDELAY but not O_NONBLOCK.
It's not clear this is needed, but it's a more-conservative change.
(create_process): Assume FD_CLOEXEC.
(create_process, create_pty): Assume O_NOCTTY.
* src/sysdep.c (init_sys_modes, reset_sys_modes): Assume F_SETFL.
(reset_sys_modes): Use O_NONBLOCK rather than O_NDELAY.
Omit if not DOS_NT, since F_GETFL is not defined there.
(serial_open): Assume O_NONBLOCK and O_NOCTTY.
* src/term.c: Include <fcntl.h>, for flags like O_NOCTTY.
(O_NOCTTY): Remove.
(init_tty): Assume O_IGNORE_CTTY is defined to 0 on platforms that
lack it, since gnulib guarantees this.
* src/w32.c (fcntl): Test for O_NONBLOCK rather than O_NDELAY.
Fixes: debbugs:12881
Diffstat (limited to 'src/term.c')
| -rw-r--r-- | src/term.c | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/src/term.c b/src/term.c index 96549290da5..481a3423989 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -20,8 +20,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 20 | /* New redisplay, TTY faces by Gerd Moellmann <gerd@gnu.org>. */ | 20 | /* New redisplay, TTY faces by Gerd Moellmann <gerd@gnu.org>. */ |
| 21 | 21 | ||
| 22 | #include <config.h> | 22 | #include <config.h> |
| 23 | #include <stdio.h> | ||
| 24 | #include <errno.h> | 23 | #include <errno.h> |
| 24 | #include <fcntl.h> | ||
| 25 | #include <stdio.h> | ||
| 25 | #include <sys/file.h> | 26 | #include <sys/file.h> |
| 26 | #include <sys/time.h> | 27 | #include <sys/time.h> |
| 27 | #include <unistd.h> | 28 | #include <unistd.h> |
| @@ -55,14 +56,6 @@ static int been_here = -1; | |||
| 55 | #include "xterm.h" | 56 | #include "xterm.h" |
| 56 | #endif | 57 | #endif |
| 57 | 58 | ||
| 58 | #ifndef O_RDWR | ||
| 59 | #define O_RDWR 2 | ||
| 60 | #endif | ||
| 61 | |||
| 62 | #ifndef O_NOCTTY | ||
| 63 | #define O_NOCTTY 0 | ||
| 64 | #endif | ||
| 65 | |||
| 66 | /* The name of the default console device. */ | 59 | /* The name of the default console device. */ |
| 67 | #ifdef WINDOWSNT | 60 | #ifdef WINDOWSNT |
| 68 | #define DEV_TTY "CONOUT$" | 61 | #define DEV_TTY "CONOUT$" |
| @@ -2989,22 +2982,18 @@ init_tty (const char *name, const char *terminal_type, int must_succeed) | |||
| 2989 | set_tty_hooks (terminal); | 2982 | set_tty_hooks (terminal); |
| 2990 | 2983 | ||
| 2991 | { | 2984 | { |
| 2992 | int fd; | 2985 | /* Open the terminal device. */ |
| 2993 | FILE *file; | 2986 | FILE *file; |
| 2994 | 2987 | ||
| 2995 | #if O_IGNORE_CTTY | 2988 | /* If !ctty, don't recognize it as our controlling terminal, and |
| 2996 | if (!ctty) | 2989 | don't make it the controlling tty if we don't have one now. |
| 2997 | /* Open the terminal device. Don't recognize it as our | 2990 | |
| 2998 | controlling terminal, and don't make it the controlling tty | 2991 | Alas, O_IGNORE_CTTY is a GNU extension that seems to be only |
| 2999 | if we don't have one at the moment. */ | 2992 | defined on Hurd. On other systems, we need to explicitly |
| 3000 | fd = emacs_open (name, O_RDWR | O_IGNORE_CTTY | O_NOCTTY, 0); | 2993 | dissociate ourselves from the controlling tty when we want to |
| 3001 | else | 2994 | open a frame on the same terminal. */ |
| 3002 | #endif /* O_IGNORE_CTTY */ | 2995 | int flags = O_RDWR | O_NOCTTY | (ctty ? 0 : O_IGNORE_CTTY); |
| 3003 | /* Alas, O_IGNORE_CTTY is a GNU extension that seems to be only | 2996 | int fd = emacs_open (name, flags, 0); |
| 3004 | defined on Hurd. On other systems, we need to explicitly | ||
| 3005 | dissociate ourselves from the controlling tty when we want to | ||
| 3006 | open a frame on the same terminal. */ | ||
| 3007 | fd = emacs_open (name, O_RDWR | O_NOCTTY, 0); | ||
| 3008 | 2997 | ||
| 3009 | tty->name = xstrdup (name); | 2998 | tty->name = xstrdup (name); |
| 3010 | terminal->name = xstrdup (name); | 2999 | terminal->name = xstrdup (name); |
| @@ -3023,10 +3012,8 @@ init_tty (const char *name, const char *terminal_type, int must_succeed) | |||
| 3023 | name); | 3012 | name); |
| 3024 | } | 3013 | } |
| 3025 | 3014 | ||
| 3026 | #if !O_IGNORE_CTTY | 3015 | if (!O_IGNORE_CTTY && !ctty) |
| 3027 | if (!ctty) | ||
| 3028 | dissociate_if_controlling_tty (fd); | 3016 | dissociate_if_controlling_tty (fd); |
| 3029 | #endif | ||
| 3030 | 3017 | ||
| 3031 | file = fdopen (fd, "w+"); | 3018 | file = fdopen (fd, "w+"); |
| 3032 | tty->input = file; | 3019 | tty->input = file; |