520c3a
From 5396b6b77d0248678f716038dc747d6898acb0b3 Mon Sep 17 00:00:00 2001
520c3a
From: Stephen Gallagher <sgallagh@redhat.com>
520c3a
Date: Fri, 22 Jan 2021 09:49:13 -0500
520c3a
Subject: [PATCH] Test for fsync on tty
520c3a
520c3a
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
520c3a
6b7b49
Modified for less 581.2 Filip Januš <fjanus@redhat.com>
6b7b49
diff -ur less-581.2/configure.ac less_fsync/configure.ac
6b7b49
--- less-581.2/configure.ac	2021-04-28 17:00:08.000000000 +0200
6b7b49
+++ less_fsync/configure.ac	2021-05-06 10:59:07.560062397 +0200
6b7b49
@@ -221,6 +221,8 @@
520c3a
 	[Define HAVE_TIME_T if your system supports the "time_t" type.])
520c3a
 AH_TEMPLATE([HAVE_STRERROR],
520c3a
 	[Define HAVE_STRERROR if you have the strerror() function.])
520c3a
+AH_TEMPLATE([HAVE_FSYNC],
520c3a
+	[Define HAVE_FSYNC if fsync() on a tty works.])
520c3a
 AH_TEMPLATE([HAVE_FILENO],
520c3a
 	[Define HAVE_FILENO if you have the fileno() macro.])
520c3a
 AH_TEMPLATE([HAVE_ERRNO],
6b7b49
@@ -274,7 +276,7 @@
520c3a
 
520c3a
 # Checks for library functions.
520c3a
 AC_TYPE_SIGNAL
6b7b49
-AC_CHECK_FUNCS([fchmod fsync nanosleep poll popen realpath _setjmp sigprocmask sigsetmask snprintf stat system ttyname usleep])
6b7b49
+AC_CHECK_FUNCS([fchmod nanosleep poll popen realpath _setjmp sigprocmask sigsetmask snprintf stat system ttyname usleep])
520c3a
 
520c3a
 # AC_CHECK_FUNCS may not work for inline functions, so test these separately.
520c3a
 AC_MSG_CHECKING(for memcpy)
6b7b49
@@ -321,6 +323,16 @@
520c3a
 #endif], [static char *x; x = strerror(0);],
520c3a
   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)], [AC_MSG_RESULT(no)])
520c3a
 
520c3a
+AC_MSG_CHECKING(for fsync)
520c3a
+AC_TRY_RUN([
520c3a
+#include <fcntl.h>
520c3a
+#include <unistd.h>
520c3a
+int main(void)
520c3a
+{
520c3a
+        int fd = open("/dev/tty", O_RDWR);
520c3a
+        return fsync(fd);
520c3a
+}], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FSYNC)], [AC_MSG_RESULT(no)])
520c3a
+
520c3a
 AC_MSG_CHECKING(for sys_errlist)
520c3a
 AC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;], 
520c3a
   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)], [AC_MSG_RESULT(no)])