* gnulib-local/lib/fd-ostream.oo.c (nonintr_tcdrain): New function.
(fd_ostream::flush): Use it instead of tcdrain.
* gnulib-local/lib/file-ostream.oo.c: Include <errno.h>.
(nonintr_tcdrain): New function.
(file_ostream::flush): Use it instead of tcdrain.
* gnulib-local/lib/term-ostream.oo.c (nonintr_tcdrain): New function.
(term_ostream::flush): Use it instead of tcdrain.
#define BUFSIZE 4096
+#if HAVE_TCDRAIN
+
+/* EINTR handling for tcdrain().
+ This function can return -1/EINTR even though we don't have any
+ signal handlers set up, namely when we get interrupted via SIGSTOP. */
+
+static inline int
+nonintr_tcdrain (int fd)
+{
+ int retval;
+
+ do
+ retval = tcdrain (fd);
+ while (retval < 0 && errno == EINTR);
+
+ return retval;
+}
+
+#endif
+
/* Implementation of ostream_t methods. */
static void
fsync (stream->fd);
#if HAVE_TCDRAIN
/* For streams connected to a terminal: */
- tcdrain (stream->fd);
+ nonintr_tcdrain (stream->fd);
#endif
}
}
/* Specification. */
#include "file-ostream.h"
+#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#if HAVE_TCDRAIN
FILE *fp;
};
+#if HAVE_TCDRAIN
+
+/* EINTR handling for tcdrain().
+ This function can return -1/EINTR even though we don't have any
+ signal handlers set up, namely when we get interrupted via SIGSTOP. */
+
+static inline int
+nonintr_tcdrain (int fd)
+{
+ int retval;
+
+ do
+ retval = tcdrain (fd);
+ while (retval < 0 && errno == EINTR);
+
+ return retval;
+}
+
+#endif
+
/* Implementation of ostream_t methods. */
static void
fsync (fd);
#if HAVE_TCDRAIN
/* For streams connected to a terminal: */
- tcdrain (fd);
+ nonintr_tcdrain (fd);
#endif
}
}
} attributes_t;
+/* ============================ EINTR handling ============================ */
+
+#if HAVE_TCDRAIN
+
+/* EINTR handling for tcdrain().
+ This function can return -1/EINTR even though we don't have any
+ signal handlers set up, namely when we get interrupted via SIGSTOP. */
+
+static inline int
+nonintr_tcdrain (int fd)
+{
+ int retval;
+
+ do
+ retval = tcdrain (fd);
+ while (retval < 0 && errno == EINTR);
+
+ return retval;
+}
+
+#endif
+
+
/* ============================ term_ostream_t ============================ */
struct term_ostream : struct ostream
fsync (stream->fd);
#if HAVE_TCDRAIN
/* For streams connected to a terminal: */
- tcdrain (stream->fd);
+ nonintr_tcdrain (stream->fd);
#endif
}
}