Blame SOURCES/less-475-fsync.patch

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
---
520c3a
 configure.ac | 14 +++++++++++++-
520c3a
 1 file changed, 13 insertions(+), 1 deletion(-)
520c3a
520c3a
diff --git a/configure.ac b/configure.ac
520c3a
index 918807967473e01af6c5d78b1737c2d06f96b426..ce478adc1ea2d37c2b22eb46fc2b55d2ba49244e 100644
520c3a
--- a/configure.ac
520c3a
+++ b/configure.ac
520c3a
@@ -219,10 +219,12 @@ AH_TEMPLATE([HAVE_STAT_INO],
520c3a
 	[Define HAVE_STAT_INO if your struct stat has st_ino and st_dev.])
520c3a
 AH_TEMPLATE([HAVE_TIME_T],
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],
520c3a
 	[Define HAVE_ERRNO if you have the errno variable.])
520c3a
 AH_TEMPLATE([MUST_DEFINE_ERRNO],
520c3a
@@ -272,11 +274,11 @@ AC_MSG_CHECKING(for ANSI function prototypes)
520c3a
 AC_TRY_COMPILE([], [int f(int a) { return a; }],
520c3a
   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ANSI_PROTOS)], [AC_MSG_RESULT(no)])
520c3a
 
520c3a
 # Checks for library functions.
520c3a
 AC_TYPE_SIGNAL
520c3a
-AC_CHECK_FUNCS([fchmod fsync nanosleep poll popen realpath _setjmp sigprocmask sigsetmask snprintf stat system usleep])
520c3a
+AC_CHECK_FUNCS([fchmod nanosleep poll popen realpath _setjmp sigprocmask sigsetmask snprintf stat system usleep])
520c3a
 
520c3a
 # AC_CHECK_FUNCS may not work for inline functions, so test these separately.
520c3a
 AC_MSG_CHECKING(for memcpy)
520c3a
 AC_TRY_LINK([
520c3a
 #if HAVE_STRING_H
520c3a
@@ -319,10 +321,20 @@ AC_TRY_LINK([
520c3a
 #if HAVE_ERRNO_H
520c3a
 #include <errno.h>
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)])
520c3a
 
520c3a
 AC_CHECK_TYPES([sigset_t],,,[#include <signal.h>])
520c3a
-- 
520c3a
2.29.2
520c3a