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 | |
| 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
| -rw-r--r-- | ChangeLog | 6 | ||||
| -rw-r--r-- | admin/CPP-DEFINES | 3 | ||||
| -rw-r--r-- | admin/ChangeLog | 6 | ||||
| -rwxr-xr-x | admin/merge-gnulib | 2 | ||||
| -rw-r--r-- | configure.ac | 2 | ||||
| -rw-r--r-- | lib-src/ChangeLog | 5 | ||||
| -rw-r--r-- | lib-src/movemail.c | 2 | ||||
| -rw-r--r-- | lib-src/update-game-score.c | 2 | ||||
| -rw-r--r-- | lib/gnulib.mk | 2 | ||||
| -rw-r--r-- | nt/ChangeLog | 10 | ||||
| -rw-r--r-- | nt/inc/sys/socket.h | 2 | ||||
| -rw-r--r-- | nt/inc/unistd.h | 13 | ||||
| -rw-r--r-- | src/ChangeLog | 27 | ||||
| -rw-r--r-- | src/callproc.c | 11 | ||||
| -rw-r--r-- | src/emacs.c | 4 | ||||
| -rw-r--r-- | src/keyboard.c | 4 | ||||
| -rw-r--r-- | src/nsterm.m | 5 | ||||
| -rw-r--r-- | src/process.c | 74 | ||||
| -rw-r--r-- | src/sysdep.c | 26 | ||||
| -rw-r--r-- | src/term.c | 39 | ||||
| -rw-r--r-- | src/w32.c | 2 |
21 files changed, 101 insertions, 146 deletions
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-11-17 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Assume POSIX 1003.1-1988 or later for fcntl.h (Bug#12881). | ||
| 4 | * configure.ac: Do not check for fcntl.h. | ||
| 5 | * lib/gnulib.mk: Regenerate. | ||
| 6 | |||
| 1 | 2012-11-16 Paul Eggert <eggert@cs.ucla.edu> | 7 | 2012-11-16 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 8 | ||
| 3 | Remove no-longer-used pty_max_bytes variable. | 9 | Remove no-longer-used pty_max_bytes variable. |
diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES index 17c56dc7e9e..ae8673452a3 100644 --- a/admin/CPP-DEFINES +++ b/admin/CPP-DEFINES | |||
| @@ -150,7 +150,6 @@ HAVE_ENDGRENT | |||
| 150 | HAVE_ENDPWENT | 150 | HAVE_ENDPWENT |
| 151 | HAVE_ENVIRON_DECL | 151 | HAVE_ENVIRON_DECL |
| 152 | HAVE_EUIDACCESS | 152 | HAVE_EUIDACCESS |
| 153 | HAVE_FCNTL_H | ||
| 154 | HAVE_FORK | 153 | HAVE_FORK |
| 155 | HAVE_FREEIFADDRS | 154 | HAVE_FREEIFADDRS |
| 156 | HAVE_FREETYPE | 155 | HAVE_FREETYPE |
| @@ -419,8 +418,6 @@ NSIG | |||
| 419 | NSIG_MINIMUM | 418 | NSIG_MINIMUM |
| 420 | NULL_DEVICE | 419 | NULL_DEVICE |
| 421 | ORDINARY_LINK | 420 | ORDINARY_LINK |
| 422 | O_RDONLY | ||
| 423 | O_RDWR | ||
| 424 | PAGESIZE | 421 | PAGESIZE |
| 425 | PREFER_VSUSP | 422 | PREFER_VSUSP |
| 426 | PTY_ITERATION | 423 | PTY_ITERATION |
diff --git a/admin/ChangeLog b/admin/ChangeLog index 4eb413e948f..3d76f9dd2ba 100644 --- a/admin/ChangeLog +++ b/admin/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-11-17 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Assume POSIX 1003.1-1988 or later for fcntl.h (Bug#12881). | ||
| 4 | * CPP-DEFINES (O_RDONLY, O_RDWR, HAVE_FCNTL_H): Remove. | ||
| 5 | * merge-gnulib (GNULIB_MODULES): Add fcntl-h. | ||
| 6 | |||
| 1 | 2012-11-16 Paul Eggert <eggert@cs.ucla.edu> | 7 | 2012-11-16 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 8 | ||
| 3 | Remove no-longer-used pty_max_bytes variable. | 9 | Remove no-longer-used pty_max_bytes variable. |
diff --git a/admin/merge-gnulib b/admin/merge-gnulib index f7a675e5101..792818b2efe 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib | |||
| @@ -29,7 +29,7 @@ GNULIB_MODULES=' | |||
| 29 | alloca-opt c-ctype c-strcase | 29 | alloca-opt c-ctype c-strcase |
| 30 | careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 | 30 | careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 |
| 31 | dtoastr dtotimespec dup2 environ execinfo faccessat | 31 | dtoastr dtotimespec dup2 environ execinfo faccessat |
| 32 | filemode getloadavg getopt-gnu gettime gettimeofday | 32 | fcntl-h filemode getloadavg getopt-gnu gettime gettimeofday |
| 33 | ignore-value intprops largefile lstat | 33 | ignore-value intprops largefile lstat |
| 34 | manywarnings mktime pselect pthread_sigmask readlink | 34 | manywarnings mktime pselect pthread_sigmask readlink |
| 35 | socklen stat-time stdalign stdarg stdbool stdio | 35 | socklen stat-time stdalign stdarg stdbool stdio |
diff --git a/configure.ac b/configure.ac index 937c645bb58..1884cc7ccf7 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -1268,7 +1268,7 @@ fi | |||
| 1268 | dnl checks for header files | 1268 | dnl checks for header files |
| 1269 | AC_CHECK_HEADERS_ONCE( | 1269 | AC_CHECK_HEADERS_ONCE( |
| 1270 | linux/version.h sys/systeminfo.h | 1270 | linux/version.h sys/systeminfo.h |
| 1271 | fcntl.h coff.h pty.h | 1271 | coff.h pty.h |
| 1272 | sys/vlimit.h sys/resource.h | 1272 | sys/vlimit.h sys/resource.h |
| 1273 | sys/utsname.h pwd.h utmp.h dirent.h util.h) | 1273 | sys/utsname.h pwd.h utmp.h dirent.h util.h) |
| 1274 | 1274 | ||
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 03cddc6a035..599e005b4e0 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-11-17 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Assume POSIX 1003.1-1988 or later for fcntl.h (Bug#12881). | ||
| 4 | * movemail.c, update-game-score.c: Assume <fcntl.h> exists. | ||
| 5 | |||
| 1 | 2012-10-26 Glenn Morris <rgm@gnu.org> | 6 | 2012-10-26 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * Makefile.in (uninstall): No INSTALLABLES live in archlibdir. | 8 | * Makefile.in (uninstall): No INSTALLABLES live in archlibdir. |
diff --git a/lib-src/movemail.c b/lib-src/movemail.c index 32d32e69abf..cd329a110a8 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c | |||
| @@ -65,9 +65,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 65 | 65 | ||
| 66 | #include <getopt.h> | 66 | #include <getopt.h> |
| 67 | #include <unistd.h> | 67 | #include <unistd.h> |
| 68 | #ifdef HAVE_FCNTL_H | ||
| 69 | #include <fcntl.h> | 68 | #include <fcntl.h> |
| 70 | #endif | ||
| 71 | #include <string.h> | 69 | #include <string.h> |
| 72 | #include "syswait.h" | 70 | #include "syswait.h" |
| 73 | #ifdef MAIL_USE_POP | 71 | #ifdef MAIL_USE_POP |
diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c index 40397536fad..59cab61aa29 100644 --- a/lib-src/update-game-score.c +++ b/lib-src/update-game-score.c | |||
| @@ -42,9 +42,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 42 | #include <time.h> | 42 | #include <time.h> |
| 43 | #include <pwd.h> | 43 | #include <pwd.h> |
| 44 | #include <ctype.h> | 44 | #include <ctype.h> |
| 45 | #ifdef HAVE_FCNTL_H | ||
| 46 | #include <fcntl.h> | 45 | #include <fcntl.h> |
| 47 | #endif | ||
| 48 | #include <sys/stat.h> | 46 | #include <sys/stat.h> |
| 49 | #include <getopt.h> | 47 | #include <getopt.h> |
| 50 | 48 | ||
diff --git a/lib/gnulib.mk b/lib/gnulib.mk index f74c46ae9c8..834f63169e2 100644 --- a/lib/gnulib.mk +++ b/lib/gnulib.mk | |||
| @@ -21,7 +21,7 @@ | |||
| 21 | # the same distribution terms as the rest of that program. | 21 | # the same distribution terms as the rest of that program. |
| 22 | # | 22 | # |
| 23 | # Generated by gnulib-tool. | 23 | # Generated by gnulib-tool. |
| 24 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=at-internal --avoid=errno --avoid=fchdir --avoid=fcntl --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=openat-die --avoid=openat-h --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask readlink socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub utimens warnings | 24 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=at-internal --avoid=errno --avoid=fchdir --avoid=fcntl --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=openat-die --avoid=openat-h --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl-h filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask readlink socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub utimens warnings |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | MOSTLYCLEANFILES += core *.stackdump | 27 | MOSTLYCLEANFILES += core *.stackdump |
diff --git a/nt/ChangeLog b/nt/ChangeLog index b24acae8be5..910ef2170c6 100644 --- a/nt/ChangeLog +++ b/nt/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2012-11-17 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Assume POSIX 1003.1-1988 or later for fcntl.h (Bug#12881). | ||
| 4 | * inc/sys/socket.h (O_NONBLOCK): Rename from O_NDELAY, since the | ||
| 5 | POSIX name for this flag is O_NONBLOCK. All uses changed. | ||
| 6 | * inc/unistd.h (O_RDWR, O_NOCTTY): New macros. Like AT_FDCWD etc. | ||
| 7 | these really should be moved to a replacement <fcntl.h> if and | ||
| 8 | when that gets implemented. In the meantime, include <fcntl.h> | ||
| 9 | to make sure we don't override its definitions. | ||
| 10 | |||
| 1 | 2012-11-17 Eli Zaretskii <eliz@gnu.org> | 11 | 2012-11-17 Eli Zaretskii <eliz@gnu.org> |
| 2 | 12 | ||
| 3 | * inc/sys/wait.h: New file, with prototype of waitpid and | 13 | * inc/sys/wait.h: New file, with prototype of waitpid and |
diff --git a/nt/inc/sys/socket.h b/nt/inc/sys/socket.h index 70225a9c82f..95fee4c4659 100644 --- a/nt/inc/sys/socket.h +++ b/nt/inc/sys/socket.h | |||
| @@ -119,7 +119,7 @@ int sys_sendto (int s, const char * buf, int len, int flags, | |||
| 119 | an fcntl function, for setting sockets to non-blocking mode. */ | 119 | an fcntl function, for setting sockets to non-blocking mode. */ |
| 120 | int fcntl (int s, int cmd, int options); | 120 | int fcntl (int s, int cmd, int options); |
| 121 | #define F_SETFL 4 | 121 | #define F_SETFL 4 |
| 122 | #define O_NDELAY 04000 | 122 | #define O_NONBLOCK 04000 |
| 123 | 123 | ||
| 124 | /* we are providing a real h_errno variable */ | 124 | /* we are providing a real h_errno variable */ |
| 125 | #undef h_errno | 125 | #undef h_errno |
diff --git a/nt/inc/unistd.h b/nt/inc/unistd.h index b0f3092cafb..0173fdbb943 100644 --- a/nt/inc/unistd.h +++ b/nt/inc/unistd.h | |||
| @@ -26,4 +26,17 @@ extern int faccessat (int, char const *, int, int); | |||
| 26 | #define AT_EACCESS 4 | 26 | #define AT_EACCESS 4 |
| 27 | #define AT_SYMLINK_NOFOLLOW 4096 | 27 | #define AT_SYMLINK_NOFOLLOW 4096 |
| 28 | 28 | ||
| 29 | /* Here are some more fcntl.h macros that default to gnulib-compatible | ||
| 30 | values. Include <fcntl.h> first, to make sure we don't override | ||
| 31 | its values if any. FIXME: If we know <fcntl.h> does not define | ||
| 32 | O_NOCTTY and O_RDWR, this can be replaced with a simple "#define | ||
| 33 | O_NOCTTY 0" and "#define O_RDWR 2". */ | ||
| 34 | #include <fcntl.h> | ||
| 35 | #ifndef O_NOCTTY | ||
| 36 | #define O_NOCTTY 0 | ||
| 37 | #endif | ||
| 38 | #ifndef O_RDWR | ||
| 39 | #define O_RDWR 2 | ||
| 40 | #endif | ||
| 41 | |||
| 29 | #endif /* _UNISTD_H */ | 42 | #endif /* _UNISTD_H */ |
diff --git a/src/ChangeLog b/src/ChangeLog index df8bf602afe..a847a3913dd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,30 @@ | |||
| 1 | 2012-11-17 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Assume POSIX 1003.1-1988 or later for fcntl.h (Bug#12881). | ||
| 4 | * callproc.c (relocate_fd): Assume F_DUPFD. | ||
| 5 | * emacs.c, term.c (O_RDWR): Remove. | ||
| 6 | * keyboard.c (tty_read_avail_input): Use O_NONBLOCK rather than | ||
| 7 | O_NDELAY, since O_NONBLOCK is the standard name for this flag. | ||
| 8 | * nsterm.m: Assume <fcntl.h> exists. | ||
| 9 | * process.c (NON_BLOCKING_CONNECT, allocate_pty, create_process) | ||
| 10 | (create_pty, Fmake_network_process, server_accept_connection) | ||
| 11 | (wait_reading_process_output, init_process_emacs): | ||
| 12 | Assume O_NONBLOCK. | ||
| 13 | (wait_reading_process_output): Put in a special case for WINDOWSNT | ||
| 14 | to mimick the older behavior where it had O_NDELAY but not O_NONBLOCK. | ||
| 15 | It's not clear this is needed, but it's a more-conservative change. | ||
| 16 | (create_process): Assume FD_CLOEXEC. | ||
| 17 | (create_process, create_pty): Assume O_NOCTTY. | ||
| 18 | * sysdep.c (init_sys_modes, reset_sys_modes): Assume F_SETFL. | ||
| 19 | (reset_sys_modes): Use O_NONBLOCK rather than O_NDELAY. | ||
| 20 | Omit if not DOS_NT, since F_GETFL is not defined there. | ||
| 21 | (serial_open): Assume O_NONBLOCK and O_NOCTTY. | ||
| 22 | * term.c: Include <fcntl.h>, for flags like O_NOCTTY. | ||
| 23 | (O_NOCTTY): Remove. | ||
| 24 | (init_tty): Assume O_IGNORE_CTTY is defined to 0 on platforms that | ||
| 25 | lack it, since gnulib guarantees this. | ||
| 26 | * w32.c (fcntl): Test for O_NONBLOCK rather than O_NDELAY. | ||
| 27 | |||
| 1 | 2012-11-17 Eli Zaretskii <eliz@gnu.org> | 28 | 2012-11-17 Eli Zaretskii <eliz@gnu.org> |
| 2 | 29 | ||
| 3 | * w32.c (faccessat): Pretend that directories have the execute bit | 30 | * w32.c (faccessat): Pretend that directories have the execute bit |
diff --git a/src/callproc.c b/src/callproc.c index 8ecaba2b408..c9a504746b3 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -1317,16 +1317,7 @@ relocate_fd (int fd, int minfd) | |||
| 1317 | return fd; | 1317 | return fd; |
| 1318 | else | 1318 | else |
| 1319 | { | 1319 | { |
| 1320 | int new; | 1320 | int new = fcntl (fd, F_DUPFD, minfd); |
| 1321 | #ifdef F_DUPFD | ||
| 1322 | new = fcntl (fd, F_DUPFD, minfd); | ||
| 1323 | #else | ||
| 1324 | new = dup (fd); | ||
| 1325 | if (new != -1) | ||
| 1326 | /* Note that we hold the original FD open while we recurse, | ||
| 1327 | to guarantee we'll get a new FD if we need it. */ | ||
| 1328 | new = relocate_fd (new, minfd); | ||
| 1329 | #endif | ||
| 1330 | if (new == -1) | 1321 | if (new == -1) |
| 1331 | { | 1322 | { |
| 1332 | const char *message_1 = "Error while setting up child: "; | 1323 | const char *message_1 = "Error while setting up child: "; |
diff --git a/src/emacs.c b/src/emacs.c index fee9c332c55..d69dbfda7bf 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -95,10 +95,6 @@ extern void moncontrol (int mode); | |||
| 95 | #include <sys/personality.h> | 95 | #include <sys/personality.h> |
| 96 | #endif | 96 | #endif |
| 97 | 97 | ||
| 98 | #ifndef O_RDWR | ||
| 99 | #define O_RDWR 2 | ||
| 100 | #endif | ||
| 101 | |||
| 102 | static const char emacs_version[] = VERSION; | 98 | static const char emacs_version[] = VERSION; |
| 103 | static const char emacs_copyright[] = COPYRIGHT; | 99 | static const char emacs_copyright[] = COPYRIGHT; |
| 104 | 100 | ||
diff --git a/src/keyboard.c b/src/keyboard.c index 8f3a206139d..951d4ad79dc 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -6948,7 +6948,7 @@ tty_read_avail_input (struct terminal *terminal, | |||
| 6948 | #elif defined USG || defined CYGWIN | 6948 | #elif defined USG || defined CYGWIN |
| 6949 | /* Read some input if available, but don't wait. */ | 6949 | /* Read some input if available, but don't wait. */ |
| 6950 | n_to_read = sizeof cbuf; | 6950 | n_to_read = sizeof cbuf; |
| 6951 | fcntl (fileno (tty->input), F_SETFL, O_NDELAY); | 6951 | fcntl (fileno (tty->input), F_SETFL, O_NONBLOCK); |
| 6952 | #else | 6952 | #else |
| 6953 | # error "Cannot read without possibly delaying" | 6953 | # error "Cannot read without possibly delaying" |
| 6954 | #endif | 6954 | #endif |
| @@ -6982,7 +6982,7 @@ tty_read_avail_input (struct terminal *terminal, | |||
| 6982 | } | 6982 | } |
| 6983 | while ( | 6983 | while ( |
| 6984 | /* We used to retry the read if it was interrupted. | 6984 | /* We used to retry the read if it was interrupted. |
| 6985 | But this does the wrong thing when O_NDELAY causes | 6985 | But this does the wrong thing when O_NONBLOCK causes |
| 6986 | an EAGAIN error. Does anybody know of a situation | 6986 | an EAGAIN error. Does anybody know of a situation |
| 6987 | where a retry is actually needed? */ | 6987 | where a retry is actually needed? */ |
| 6988 | #if 0 | 6988 | #if 0 |
diff --git a/src/nsterm.m b/src/nsterm.m index 3640ac0c5e8..8773c6faf9f 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -30,6 +30,7 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) | |||
| 30 | interpretation of even the system includes. */ | 30 | interpretation of even the system includes. */ |
| 31 | #include <config.h> | 31 | #include <config.h> |
| 32 | 32 | ||
| 33 | #include <fcntl.h> | ||
| 33 | #include <math.h> | 34 | #include <math.h> |
| 34 | #include <pthread.h> | 35 | #include <pthread.h> |
| 35 | #include <sys/types.h> | 36 | #include <sys/types.h> |
| @@ -41,10 +42,6 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) | |||
| 41 | #include <c-strcase.h> | 42 | #include <c-strcase.h> |
| 42 | #include <ftoastr.h> | 43 | #include <ftoastr.h> |
| 43 | 44 | ||
| 44 | #ifdef HAVE_FCNTL_H | ||
| 45 | #include <fcntl.h> | ||
| 46 | #endif | ||
| 47 | |||
| 48 | #include "lisp.h" | 45 | #include "lisp.h" |
| 49 | #include "blockinput.h" | 46 | #include "blockinput.h" |
| 50 | #include "sysselect.h" | 47 | #include "sysselect.h" |
diff --git a/src/process.c b/src/process.c index 51648187aff..0036ce595f5 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -196,11 +196,9 @@ static EMACS_INT update_tick; | |||
| 196 | #ifndef NON_BLOCKING_CONNECT | 196 | #ifndef NON_BLOCKING_CONNECT |
| 197 | #ifdef HAVE_SELECT | 197 | #ifdef HAVE_SELECT |
| 198 | #if defined (HAVE_GETPEERNAME) || defined (GNU_LINUX) | 198 | #if defined (HAVE_GETPEERNAME) || defined (GNU_LINUX) |
| 199 | #if O_NONBLOCK || O_NDELAY | ||
| 200 | #if defined (EWOULDBLOCK) || defined (EINPROGRESS) | 199 | #if defined (EWOULDBLOCK) || defined (EINPROGRESS) |
| 201 | #define NON_BLOCKING_CONNECT | 200 | #define NON_BLOCKING_CONNECT |
| 202 | #endif /* EWOULDBLOCK || EINPROGRESS */ | 201 | #endif /* EWOULDBLOCK || EINPROGRESS */ |
| 203 | #endif /* O_NONBLOCK || O_NDELAY */ | ||
| 204 | #endif /* HAVE_GETPEERNAME || GNU_LINUX */ | 202 | #endif /* HAVE_GETPEERNAME || GNU_LINUX */ |
| 205 | #endif /* HAVE_SELECT */ | 203 | #endif /* HAVE_SELECT */ |
| 206 | #endif /* NON_BLOCKING_CONNECT */ | 204 | #endif /* NON_BLOCKING_CONNECT */ |
| @@ -639,13 +637,7 @@ allocate_pty (void) | |||
| 639 | #ifdef PTY_OPEN | 637 | #ifdef PTY_OPEN |
| 640 | PTY_OPEN; | 638 | PTY_OPEN; |
| 641 | #else /* no PTY_OPEN */ | 639 | #else /* no PTY_OPEN */ |
| 642 | { | 640 | fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0); |
| 643 | # if O_NONBLOCK | ||
| 644 | fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0); | ||
| 645 | # else | ||
| 646 | fd = emacs_open (pty_name, O_RDWR | O_NDELAY, 0); | ||
| 647 | # endif | ||
| 648 | } | ||
| 649 | #endif /* no PTY_OPEN */ | 641 | #endif /* no PTY_OPEN */ |
| 650 | 642 | ||
| 651 | if (fd >= 0) | 643 | if (fd >= 0) |
| @@ -1583,7 +1575,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1583 | int inchannel, outchannel; | 1575 | int inchannel, outchannel; |
| 1584 | pid_t pid; | 1576 | pid_t pid; |
| 1585 | int sv[2]; | 1577 | int sv[2]; |
| 1586 | #if !defined (WINDOWSNT) && defined (FD_CLOEXEC) | 1578 | #ifndef WINDOWSNT |
| 1587 | int wait_child_setup[2]; | 1579 | int wait_child_setup[2]; |
| 1588 | #endif | 1580 | #endif |
| 1589 | #ifdef SIGCHLD | 1581 | #ifdef SIGCHLD |
| @@ -1609,13 +1601,9 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1609 | #if ! defined (USG) || defined (USG_SUBTTY_WORKS) | 1601 | #if ! defined (USG) || defined (USG_SUBTTY_WORKS) |
| 1610 | /* On most USG systems it does not work to open the pty's tty here, | 1602 | /* On most USG systems it does not work to open the pty's tty here, |
| 1611 | then close it and reopen it in the child. */ | 1603 | then close it and reopen it in the child. */ |
| 1612 | #if O_NOCTTY | ||
| 1613 | /* Don't let this terminal become our controlling terminal | 1604 | /* Don't let this terminal become our controlling terminal |
| 1614 | (in case we don't have one). */ | 1605 | (in case we don't have one). */ |
| 1615 | forkout = forkin = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); | 1606 | forkout = forkin = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); |
| 1616 | #else | ||
| 1617 | forkout = forkin = emacs_open (pty_name, O_RDWR, 0); | ||
| 1618 | #endif | ||
| 1619 | if (forkin < 0) | 1607 | if (forkin < 0) |
| 1620 | report_file_error ("Opening pty", Qnil); | 1608 | report_file_error ("Opening pty", Qnil); |
| 1621 | #else | 1609 | #else |
| @@ -1644,7 +1632,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1644 | forkin = sv[0]; | 1632 | forkin = sv[0]; |
| 1645 | } | 1633 | } |
| 1646 | 1634 | ||
| 1647 | #if !defined (WINDOWSNT) && defined (FD_CLOEXEC) | 1635 | #ifndef WINDOWSNT |
| 1648 | { | 1636 | { |
| 1649 | int tem; | 1637 | int tem; |
| 1650 | 1638 | ||
| @@ -1663,15 +1651,8 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1663 | } | 1651 | } |
| 1664 | #endif | 1652 | #endif |
| 1665 | 1653 | ||
| 1666 | #if O_NONBLOCK | ||
| 1667 | fcntl (inchannel, F_SETFL, O_NONBLOCK); | 1654 | fcntl (inchannel, F_SETFL, O_NONBLOCK); |
| 1668 | fcntl (outchannel, F_SETFL, O_NONBLOCK); | 1655 | fcntl (outchannel, F_SETFL, O_NONBLOCK); |
| 1669 | #else | ||
| 1670 | #if O_NDELAY | ||
| 1671 | fcntl (inchannel, F_SETFL, O_NDELAY); | ||
| 1672 | fcntl (outchannel, F_SETFL, O_NDELAY); | ||
| 1673 | #endif | ||
| 1674 | #endif | ||
| 1675 | 1656 | ||
| 1676 | /* Record this as an active process, with its channels. | 1657 | /* Record this as an active process, with its channels. |
| 1677 | As a result, child_setup will close Emacs's side of the pipes. */ | 1658 | As a result, child_setup will close Emacs's side of the pipes. */ |
| @@ -1830,9 +1811,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1830 | pid = child_setup (xforkin, xforkout, xforkout, | 1811 | pid = child_setup (xforkin, xforkout, xforkout, |
| 1831 | new_argv, 1, encoded_current_dir); | 1812 | new_argv, 1, encoded_current_dir); |
| 1832 | #else /* not WINDOWSNT */ | 1813 | #else /* not WINDOWSNT */ |
| 1833 | #ifdef FD_CLOEXEC | ||
| 1834 | emacs_close (wait_child_setup[0]); | 1814 | emacs_close (wait_child_setup[0]); |
| 1835 | #endif | ||
| 1836 | child_setup (xforkin, xforkout, xforkout, | 1815 | child_setup (xforkin, xforkout, xforkout, |
| 1837 | new_argv, 1, encoded_current_dir); | 1816 | new_argv, 1, encoded_current_dir); |
| 1838 | #endif /* not WINDOWSNT */ | 1817 | #endif /* not WINDOWSNT */ |
| @@ -1891,7 +1870,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1891 | 1870 | ||
| 1892 | pset_tty_name (XPROCESS (process), lisp_pty_name); | 1871 | pset_tty_name (XPROCESS (process), lisp_pty_name); |
| 1893 | 1872 | ||
| 1894 | #if !defined (WINDOWSNT) && defined (FD_CLOEXEC) | 1873 | #ifndef WINDOWSNT |
| 1895 | /* Wait for child_setup to complete in case that vfork is | 1874 | /* Wait for child_setup to complete in case that vfork is |
| 1896 | actually defined as fork. The descriptor wait_child_setup[1] | 1875 | actually defined as fork. The descriptor wait_child_setup[1] |
| 1897 | of a pipe is closed at the child side either by close-on-exec | 1876 | of a pipe is closed at the child side either by close-on-exec |
| @@ -1928,13 +1907,9 @@ create_pty (Lisp_Object process) | |||
| 1928 | #if ! defined (USG) || defined (USG_SUBTTY_WORKS) | 1907 | #if ! defined (USG) || defined (USG_SUBTTY_WORKS) |
| 1929 | /* On most USG systems it does not work to open the pty's tty here, | 1908 | /* On most USG systems it does not work to open the pty's tty here, |
| 1930 | then close it and reopen it in the child. */ | 1909 | then close it and reopen it in the child. */ |
| 1931 | #if O_NOCTTY | ||
| 1932 | /* Don't let this terminal become our controlling terminal | 1910 | /* Don't let this terminal become our controlling terminal |
| 1933 | (in case we don't have one). */ | 1911 | (in case we don't have one). */ |
| 1934 | int forkout = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); | 1912 | int forkout = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); |
| 1935 | #else | ||
| 1936 | int forkout = emacs_open (pty_name, O_RDWR, 0); | ||
| 1937 | #endif | ||
| 1938 | if (forkout < 0) | 1913 | if (forkout < 0) |
| 1939 | report_file_error ("Opening pty", Qnil); | 1914 | report_file_error ("Opening pty", Qnil); |
| 1940 | #if defined (DONT_REOPEN_PTY) | 1915 | #if defined (DONT_REOPEN_PTY) |
| @@ -1948,15 +1923,8 @@ create_pty (Lisp_Object process) | |||
| 1948 | } | 1923 | } |
| 1949 | #endif /* HAVE_PTYS */ | 1924 | #endif /* HAVE_PTYS */ |
| 1950 | 1925 | ||
| 1951 | #if O_NONBLOCK | ||
| 1952 | fcntl (inchannel, F_SETFL, O_NONBLOCK); | 1926 | fcntl (inchannel, F_SETFL, O_NONBLOCK); |
| 1953 | fcntl (outchannel, F_SETFL, O_NONBLOCK); | 1927 | fcntl (outchannel, F_SETFL, O_NONBLOCK); |
| 1954 | #else | ||
| 1955 | #if O_NDELAY | ||
| 1956 | fcntl (inchannel, F_SETFL, O_NDELAY); | ||
| 1957 | fcntl (outchannel, F_SETFL, O_NDELAY); | ||
| 1958 | #endif | ||
| 1959 | #endif | ||
| 1960 | 1928 | ||
| 1961 | /* Record this as an active process, with its channels. | 1929 | /* Record this as an active process, with its channels. |
| 1962 | As a result, child_setup will close Emacs's side of the pipes. */ | 1930 | As a result, child_setup will close Emacs's side of the pipes. */ |
| @@ -2912,13 +2880,9 @@ usage: (make-network-process &rest ARGS) */) | |||
| 2912 | { | 2880 | { |
| 2913 | /* Don't support network sockets when non-blocking mode is | 2881 | /* Don't support network sockets when non-blocking mode is |
| 2914 | not available, since a blocked Emacs is not useful. */ | 2882 | not available, since a blocked Emacs is not useful. */ |
| 2915 | #if !O_NONBLOCK && !O_NDELAY | ||
| 2916 | error ("Network servers not supported"); | ||
| 2917 | #else | ||
| 2918 | is_server = 1; | 2883 | is_server = 1; |
| 2919 | if (TYPE_RANGED_INTEGERP (int, tem)) | 2884 | if (TYPE_RANGED_INTEGERP (int, tem)) |
| 2920 | backlog = XINT (tem); | 2885 | backlog = XINT (tem); |
| 2921 | #endif | ||
| 2922 | } | 2886 | } |
| 2923 | 2887 | ||
| 2924 | /* Make QCaddress an alias for :local (server) or :remote (client). */ | 2888 | /* Make QCaddress an alias for :local (server) or :remote (client). */ |
| @@ -3178,11 +3142,7 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3178 | #ifdef NON_BLOCKING_CONNECT | 3142 | #ifdef NON_BLOCKING_CONNECT |
| 3179 | if (is_non_blocking_client) | 3143 | if (is_non_blocking_client) |
| 3180 | { | 3144 | { |
| 3181 | #if O_NONBLOCK | ||
| 3182 | ret = fcntl (s, F_SETFL, O_NONBLOCK); | 3145 | ret = fcntl (s, F_SETFL, O_NONBLOCK); |
| 3183 | #else | ||
| 3184 | ret = fcntl (s, F_SETFL, O_NDELAY); | ||
| 3185 | #endif | ||
| 3186 | if (ret < 0) | 3146 | if (ret < 0) |
| 3187 | { | 3147 | { |
| 3188 | xerrno = errno; | 3148 | xerrno = errno; |
| @@ -3395,13 +3355,7 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3395 | 3355 | ||
| 3396 | chan_process[inch] = proc; | 3356 | chan_process[inch] = proc; |
| 3397 | 3357 | ||
| 3398 | #if O_NONBLOCK | ||
| 3399 | fcntl (inch, F_SETFL, O_NONBLOCK); | 3358 | fcntl (inch, F_SETFL, O_NONBLOCK); |
| 3400 | #else | ||
| 3401 | #if O_NDELAY | ||
| 3402 | fcntl (inch, F_SETFL, O_NDELAY); | ||
| 3403 | #endif | ||
| 3404 | #endif | ||
| 3405 | 3359 | ||
| 3406 | p = XPROCESS (proc); | 3360 | p = XPROCESS (proc); |
| 3407 | 3361 | ||
| @@ -4130,13 +4084,7 @@ server_accept_connection (Lisp_Object server, int channel) | |||
| 4130 | 4084 | ||
| 4131 | chan_process[s] = proc; | 4085 | chan_process[s] = proc; |
| 4132 | 4086 | ||
| 4133 | #if O_NONBLOCK | ||
| 4134 | fcntl (s, F_SETFL, O_NONBLOCK); | 4087 | fcntl (s, F_SETFL, O_NONBLOCK); |
| 4135 | #else | ||
| 4136 | #if O_NDELAY | ||
| 4137 | fcntl (s, F_SETFL, O_NDELAY); | ||
| 4138 | #endif | ||
| 4139 | #endif | ||
| 4140 | 4088 | ||
| 4141 | p = XPROCESS (proc); | 4089 | p = XPROCESS (proc); |
| 4142 | 4090 | ||
| @@ -4832,23 +4780,17 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 4832 | else if (nread == -1 && errno == EWOULDBLOCK) | 4780 | else if (nread == -1 && errno == EWOULDBLOCK) |
| 4833 | ; | 4781 | ; |
| 4834 | #endif | 4782 | #endif |
| 4835 | /* ISC 4.1 defines both EWOULDBLOCK and O_NONBLOCK, | ||
| 4836 | and Emacs uses O_NONBLOCK, so what we get is EAGAIN. */ | ||
| 4837 | #if O_NONBLOCK | ||
| 4838 | else if (nread == -1 && errno == EAGAIN) | ||
| 4839 | ; | ||
| 4840 | #else | ||
| 4841 | #if O_NDELAY | ||
| 4842 | else if (nread == -1 && errno == EAGAIN) | 4783 | else if (nread == -1 && errno == EAGAIN) |
| 4843 | ; | 4784 | ; |
| 4785 | #ifdef WINDOWSNT | ||
| 4786 | /* FIXME: Is this special case still needed? */ | ||
| 4844 | /* Note that we cannot distinguish between no input | 4787 | /* Note that we cannot distinguish between no input |
| 4845 | available now and a closed pipe. | 4788 | available now and a closed pipe. |
| 4846 | With luck, a closed pipe will be accompanied by | 4789 | With luck, a closed pipe will be accompanied by |
| 4847 | subprocess termination and SIGCHLD. */ | 4790 | subprocess termination and SIGCHLD. */ |
| 4848 | else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc)) | 4791 | else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc)) |
| 4849 | ; | 4792 | ; |
| 4850 | #endif /* O_NDELAY */ | 4793 | #endif |
| 4851 | #endif /* O_NONBLOCK */ | ||
| 4852 | #ifdef HAVE_PTYS | 4794 | #ifdef HAVE_PTYS |
| 4853 | /* On some OSs with ptys, when the process on one end of | 4795 | /* On some OSs with ptys, when the process on one end of |
| 4854 | a pty exits, the other end gets an error reading with | 4796 | a pty exits, the other end gets an error reading with |
| @@ -7312,9 +7254,7 @@ init_process_emacs (void) | |||
| 7312 | #ifdef HAVE_GETSOCKNAME | 7254 | #ifdef HAVE_GETSOCKNAME |
| 7313 | ADD_SUBFEATURE (QCservice, Qt); | 7255 | ADD_SUBFEATURE (QCservice, Qt); |
| 7314 | #endif | 7256 | #endif |
| 7315 | #if O_NONBLOCK || O_NDELAY | ||
| 7316 | ADD_SUBFEATURE (QCserver, Qt); | 7257 | ADD_SUBFEATURE (QCserver, Qt); |
| 7317 | #endif | ||
| 7318 | 7258 | ||
| 7319 | for (sopt = socket_options; sopt->name; sopt++) | 7259 | for (sopt = socket_options; sopt->name; sopt++) |
| 7320 | subfeatures = pure_cons (intern_c_string (sopt->name), subfeatures); | 7260 | subfeatures = pure_cons (intern_c_string (sopt->name), subfeatures); |
diff --git a/src/sysdep.c b/src/sysdep.c index 06dc41b511e..7c5c144fa8c 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -1036,8 +1036,7 @@ init_sys_modes (struct tty_display_info *tty_out) | |||
| 1036 | #endif | 1036 | #endif |
| 1037 | #endif | 1037 | #endif |
| 1038 | 1038 | ||
| 1039 | #ifdef F_SETFL | 1039 | #ifdef F_GETOWN |
| 1040 | #ifdef F_GETOWN /* F_SETFL does not imply existence of F_GETOWN */ | ||
| 1041 | if (interrupt_input) | 1040 | if (interrupt_input) |
| 1042 | { | 1041 | { |
| 1043 | old_fcntl_owner[fileno (tty_out->input)] = | 1042 | old_fcntl_owner[fileno (tty_out->input)] = |
| @@ -1055,7 +1054,6 @@ init_sys_modes (struct tty_display_info *tty_out) | |||
| 1055 | #endif /* HAVE_GPM */ | 1054 | #endif /* HAVE_GPM */ |
| 1056 | } | 1055 | } |
| 1057 | #endif /* F_GETOWN */ | 1056 | #endif /* F_GETOWN */ |
| 1058 | #endif /* F_SETFL */ | ||
| 1059 | 1057 | ||
| 1060 | #ifdef _IOFBF | 1058 | #ifdef _IOFBF |
| 1061 | /* This symbol is defined on recent USG systems. | 1059 | /* This symbol is defined on recent USG systems. |
| @@ -1275,8 +1273,8 @@ reset_sys_modes (struct tty_display_info *tty_out) | |||
| 1275 | fsync (fileno (tty_out->output)); | 1273 | fsync (fileno (tty_out->output)); |
| 1276 | #endif | 1274 | #endif |
| 1277 | 1275 | ||
| 1278 | #ifdef F_SETFL | 1276 | #ifndef DOS_NT |
| 1279 | #ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */ | 1277 | #ifdef F_SETOWN |
| 1280 | if (interrupt_input) | 1278 | if (interrupt_input) |
| 1281 | { | 1279 | { |
| 1282 | reset_sigio (fileno (tty_out->input)); | 1280 | reset_sigio (fileno (tty_out->input)); |
| @@ -1284,11 +1282,9 @@ reset_sys_modes (struct tty_display_info *tty_out) | |||
| 1284 | old_fcntl_owner[fileno (tty_out->input)]); | 1282 | old_fcntl_owner[fileno (tty_out->input)]); |
| 1285 | } | 1283 | } |
| 1286 | #endif /* F_SETOWN */ | 1284 | #endif /* F_SETOWN */ |
| 1287 | #if O_NDELAY | ||
| 1288 | fcntl (fileno (tty_out->input), F_SETFL, | 1285 | fcntl (fileno (tty_out->input), F_SETFL, |
| 1289 | fcntl (fileno (tty_out->input), F_GETFL, 0) & ~O_NDELAY); | 1286 | fcntl (fileno (tty_out->input), F_GETFL, 0) & ~O_NONBLOCK); |
| 1290 | #endif | 1287 | #endif |
| 1291 | #endif /* F_SETFL */ | ||
| 1292 | 1288 | ||
| 1293 | if (tty_out->old_tty) | 1289 | if (tty_out->old_tty) |
| 1294 | while (emacs_set_tty (fileno (tty_out->input), | 1290 | while (emacs_set_tty (fileno (tty_out->input), |
| @@ -2377,19 +2373,7 @@ safe_strsignal (int code) | |||
| 2377 | int | 2373 | int |
| 2378 | serial_open (char *port) | 2374 | serial_open (char *port) |
| 2379 | { | 2375 | { |
| 2380 | int fd = -1; | 2376 | int fd = emacs_open (port, O_RDWR | O_NOCTTY | O_NONBLOCK, 0); |
| 2381 | |||
| 2382 | fd = emacs_open ((char*) port, | ||
| 2383 | O_RDWR | ||
| 2384 | #if O_NONBLOCK | ||
| 2385 | | O_NONBLOCK | ||
| 2386 | #else | ||
| 2387 | | O_NDELAY | ||
| 2388 | #endif | ||
| 2389 | #if O_NOCTTY | ||
| 2390 | | O_NOCTTY | ||
| 2391 | #endif | ||
| 2392 | , 0); | ||
| 2393 | if (fd < 0) | 2377 | if (fd < 0) |
| 2394 | { | 2378 | { |
| 2395 | error ("Could not open %s: %s", | 2379 | error ("Could not open %s: %s", |
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; |
| @@ -5854,7 +5854,7 @@ fcntl (int s, int cmd, int options) | |||
| 5854 | check_errno (); | 5854 | check_errno (); |
| 5855 | if (fd_info[s].flags & FILE_SOCKET) | 5855 | if (fd_info[s].flags & FILE_SOCKET) |
| 5856 | { | 5856 | { |
| 5857 | if (cmd == F_SETFL && options == O_NDELAY) | 5857 | if (cmd == F_SETFL && options == O_NONBLOCK) |
| 5858 | { | 5858 | { |
| 5859 | unsigned long nblock = 1; | 5859 | unsigned long nblock = 1; |
| 5860 | int rc = pfn_ioctlsocket (SOCK_HANDLE (s), FIONBIO, &nblock); | 5860 | int rc = pfn_ioctlsocket (SOCK_HANDLE (s), FIONBIO, &nblock); |