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