Use tcdrain, not fdatasync, to drain ttys
fdatasync is for storage devices, not ttys. * admin/merge-gnulib (GNULIB_MODULES): Remove fdatasync. * lib/fdatasync.c, m4/fdatasync.m4: Remove. * lib-src/Makefile.in (LIB_FDATASYNC): * src/Makefile.in (LIB_FDATASYNC): Remove. All uses removed. * lib-src/emacsclient.c [!DOS_NT]: Include <termios.h>, for tcdrain. * lib-src/emacsclient.c (flush_stdout): * src/sysdep.c (reset_sys_modes): On ttys, use tcdrain instead of fdatasync (except don’t use either function if DOS_NT). * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
This commit is contained in:
parent
25a33aa2d1
commit
f5090b9129
9 changed files with 15 additions and 92 deletions
|
@ -32,7 +32,7 @@ GNULIB_MODULES='
|
|||
crypto/md5-buffer crypto/sha1-buffer crypto/sha256-buffer crypto/sha512-buffer
|
||||
d-type diffseq dosname dtoastr dtotimespec dup2
|
||||
environ execinfo explicit_bzero faccessat
|
||||
fcntl fcntl-h fdatasync fdopendir
|
||||
fcntl fcntl-h fdopendir
|
||||
filemode filevercmp flexmember fpieee fstatat fsusage fsync
|
||||
getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog
|
||||
ieee754-h ignore-value intprops largefile lstat
|
||||
|
|
|
@ -204,8 +204,6 @@ LIBRESOLV=@LIBRESOLV@
|
|||
LIBS_MAIL=@LIBS_MAIL@
|
||||
## empty or -lrt or -lposix4 if HAVE_CLOCK_GETTIME
|
||||
LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@
|
||||
## empty or -lrt or -lposix4 if HAVE_FDATASYNC
|
||||
LIB_FDATASYNC = @LIB_FDATASYNC@
|
||||
## empty or -lwsock2 for MinGW
|
||||
LIB_WSOCK32=@LIB_WSOCK32@
|
||||
|
||||
|
@ -396,12 +394,12 @@ pop.o: ${srcdir}/pop.c ${srcdir}/pop.h ${srcdir}/../lib/min-max.h $(config_h)
|
|||
|
||||
emacsclient${EXEEXT}: ${srcdir}/emacsclient.c $(NTLIB) $(config_h)
|
||||
$(AM_V_CCLD)$(CC) ${ALL_CFLAGS} $< \
|
||||
-DVERSION="\"${version}\"" $(NTLIB) $(LOADLIBES) $(LIB_FDATASYNC) \
|
||||
-DVERSION="\"${version}\"" $(NTLIB) $(LOADLIBES) \
|
||||
$(LIB_WSOCK32) $(LIBS_ECLIENT) -o $@
|
||||
|
||||
emacsclientw${EXEEXT}: ${srcdir}/emacsclient.c $(NTLIB) $(CLIENTRES) $(config_h)
|
||||
$(AM_V_CCLD)$(CC) ${ALL_CFLAGS} $(CLIENTRES) -mwindows $< \
|
||||
-DVERSION="\"${version}\"" $(LOADLIBES) $(LIB_FDATASYNC) \
|
||||
-DVERSION="\"${version}\"" $(LOADLIBES) \
|
||||
$(LIB_WSOCK32) $(LIBS_ECLIENT) -o $@
|
||||
|
||||
NTINC = ${srcdir}/../nt/inc
|
||||
|
|
|
@ -65,6 +65,10 @@ char *w32_getenv (const char *);
|
|||
|
||||
#endif /* !WINDOWSNT */
|
||||
|
||||
#ifndef DOS_NT
|
||||
# include <termios.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
|
@ -1722,8 +1726,10 @@ static void
|
|||
flush_stdout (HSOCKET emacs_socket)
|
||||
{
|
||||
fflush (stdout);
|
||||
while (fdatasync (STDOUT_FILENO) != 0 && errno == EINTR)
|
||||
#ifndef DOS_NT
|
||||
while (tcdrain (STDOUT_FILENO) != 0 && errno == EINTR)
|
||||
act_on_signals (emacs_socket);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
/* Emulate fdatasync on platforms that lack it.
|
||||
|
||||
Copyright (C) 2011-2018 Free Software Foundation, Inc.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
fdatasync (int fd)
|
||||
{
|
||||
/* This does more work than strictly necessary, but is the best we
|
||||
can do portably. */
|
||||
return fsync (fd);
|
||||
}
|
|
@ -92,7 +92,6 @@
|
|||
# faccessat \
|
||||
# fcntl \
|
||||
# fcntl-h \
|
||||
# fdatasync \
|
||||
# fdopendir \
|
||||
# filemode \
|
||||
# filevercmp \
|
||||
|
@ -731,7 +730,6 @@ LIB_ACL = @LIB_ACL@
|
|||
LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@
|
||||
LIB_EACCESS = @LIB_EACCESS@
|
||||
LIB_EXECINFO = @LIB_EXECINFO@
|
||||
LIB_FDATASYNC = @LIB_FDATASYNC@
|
||||
LIB_MATH = @LIB_MATH@
|
||||
LIB_PTHREAD = @LIB_PTHREAD@
|
||||
LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@
|
||||
|
@ -1586,17 +1584,6 @@ EXTRA_DIST += fcntl.in.h
|
|||
endif
|
||||
## end gnulib module fcntl-h
|
||||
|
||||
## begin gnulib module fdatasync
|
||||
ifeq (,$(OMIT_GNULIB_MODULE_fdatasync))
|
||||
|
||||
|
||||
EXTRA_DIST += fdatasync.c
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += fdatasync.c
|
||||
|
||||
endif
|
||||
## end gnulib module fdatasync
|
||||
|
||||
## begin gnulib module fdopendir
|
||||
ifeq (,$(OMIT_GNULIB_MODULE_fdopendir))
|
||||
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
# fdatasync.m4 serial 4
|
||||
dnl Copyright (C) 2008-2018 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_FUNC_FDATASYNC],
|
||||
[
|
||||
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
||||
|
||||
dnl Using AC_CHECK_FUNCS_ONCE would break our subsequent AC_SEARCH_LIBS
|
||||
AC_CHECK_DECLS_ONCE([fdatasync])
|
||||
LIB_FDATASYNC=
|
||||
AC_SUBST([LIB_FDATASYNC])
|
||||
|
||||
if test $ac_cv_have_decl_fdatasync = no; then
|
||||
HAVE_DECL_FDATASYNC=0
|
||||
dnl Mac OS X 10.7 has fdatasync but does not declare it.
|
||||
AC_CHECK_FUNCS([fdatasync])
|
||||
if test $ac_cv_func_fdatasync = no; then
|
||||
HAVE_FDATASYNC=0
|
||||
fi
|
||||
else
|
||||
dnl Solaris <= 2.6 has fdatasync() in libposix4.
|
||||
dnl Solaris 7..10 has it in librt.
|
||||
gl_saved_libs=$LIBS
|
||||
AC_SEARCH_LIBS([fdatasync], [rt posix4],
|
||||
[test "$ac_cv_search_fdatasync" = "none required" ||
|
||||
LIB_FDATASYNC=$ac_cv_search_fdatasync])
|
||||
LIBS=$gl_saved_libs
|
||||
fi
|
||||
])
|
|
@ -81,7 +81,6 @@ AC_DEFUN([gl_EARLY],
|
|||
# Code from module faccessat:
|
||||
# Code from module fcntl:
|
||||
# Code from module fcntl-h:
|
||||
# Code from module fdatasync:
|
||||
# Code from module fdopendir:
|
||||
# Code from module filemode:
|
||||
# Code from module filevercmp:
|
||||
|
@ -241,11 +240,6 @@ AC_DEFUN([gl_INIT],
|
|||
fi
|
||||
gl_FCNTL_MODULE_INDICATOR([fcntl])
|
||||
gl_FCNTL_H
|
||||
gl_FUNC_FDATASYNC
|
||||
if test $HAVE_FDATASYNC = 0; then
|
||||
AC_LIBOBJ([fdatasync])
|
||||
fi
|
||||
gl_UNISTD_MODULE_INDICATOR([fdatasync])
|
||||
gl_FUNC_FDOPENDIR
|
||||
if test $HAVE_FDOPENDIR = 0 || test $REPLACE_FDOPENDIR = 1; then
|
||||
AC_LIBOBJ([fdopendir])
|
||||
|
@ -880,7 +874,6 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
lib/faccessat.c
|
||||
lib/fcntl.c
|
||||
lib/fcntl.in.h
|
||||
lib/fdatasync.c
|
||||
lib/fdopendir.c
|
||||
lib/filemode.c
|
||||
lib/filemode.h
|
||||
|
@ -1028,7 +1021,6 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
m4/fcntl-o.m4
|
||||
m4/fcntl.m4
|
||||
m4/fcntl_h.m4
|
||||
m4/fdatasync.m4
|
||||
m4/fdopendir.m4
|
||||
m4/filemode.m4
|
||||
m4/flexmember.m4
|
||||
|
|
|
@ -141,7 +141,6 @@ M17N_FLT_LIBS = @M17N_FLT_LIBS@
|
|||
LIB_ACL=@LIB_ACL@
|
||||
LIB_CLOCK_GETTIME=@LIB_CLOCK_GETTIME@
|
||||
LIB_EACCESS=@LIB_EACCESS@
|
||||
LIB_FDATASYNC=@LIB_FDATASYNC@
|
||||
LIB_TIMER_TIME=@LIB_TIMER_TIME@
|
||||
|
||||
DBUS_CFLAGS = @DBUS_CFLAGS@
|
||||
|
@ -496,7 +495,7 @@ LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \
|
|||
$(LIBX_OTHER) $(LIBSOUND) \
|
||||
$(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_ACL) $(LIB_CLOCK_GETTIME) \
|
||||
$(WEBKIT_LIBS) \
|
||||
$(LIB_EACCESS) $(LIB_FDATASYNC) $(LIB_TIMER_TIME) $(DBUS_LIBS) \
|
||||
$(LIB_EACCESS) $(LIB_TIMER_TIME) $(DBUS_LIBS) \
|
||||
$(LIB_EXECINFO) $(XRANDR_LIBS) $(XINERAMA_LIBS) $(XFIXES_LIBS) \
|
||||
$(XDBE_LIBS) \
|
||||
$(LIBXML2_LIBS) $(LIBGPM) $(LIBS_SYSTEM) $(CAIRO_LIBS) \
|
||||
|
|
|
@ -1519,19 +1519,19 @@ reset_sys_modes (struct tty_display_info *tty_out)
|
|||
if (tty_out->terminal->reset_terminal_modes_hook)
|
||||
tty_out->terminal->reset_terminal_modes_hook (tty_out->terminal);
|
||||
|
||||
#ifndef DOS_NT
|
||||
/* Avoid possible loss of output when changing terminal modes. */
|
||||
while (fdatasync (fileno (tty_out->output)) != 0 && errno == EINTR)
|
||||
while (tcdrain (fileno (tty_out->output)) != 0 && errno == EINTR)
|
||||
continue;
|
||||
|
||||
#ifndef DOS_NT
|
||||
#ifdef F_SETOWN
|
||||
# ifdef F_SETOWN
|
||||
if (interrupt_input)
|
||||
{
|
||||
reset_sigio (fileno (tty_out->input));
|
||||
fcntl (fileno (tty_out->input), F_SETOWN,
|
||||
old_fcntl_owner[fileno (tty_out->input)]);
|
||||
}
|
||||
#endif /* F_SETOWN */
|
||||
# endif /* F_SETOWN */
|
||||
fcntl (fileno (tty_out->input), F_SETFL,
|
||||
fcntl (fileno (tty_out->input), F_GETFL, 0) & ~O_NONBLOCK);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue