Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/stdio Handle EINTR, from RVP.
details: https://anonhg.NetBSD.org/src/rev/b121d90d5c65
branches: trunk
changeset: 984419:b121d90d5c65
user: christos <christos%NetBSD.org@localhost>
date: Tue Jul 06 14:22:16 2021 +0000
description:
Handle EINTR, from RVP.
diffstat:
lib/libc/stdio/fflush.c | 10 +++++++---
lib/libc/stdio/fvwrite.c | 24 +++++++++++++-----------
2 files changed, 20 insertions(+), 14 deletions(-)
diffs (96 lines):
diff -r 532c028323d7 -r b121d90d5c65 lib/libc/stdio/fflush.c
--- a/lib/libc/stdio/fflush.c Tue Jul 06 12:42:12 2021 +0000
+++ b/lib/libc/stdio/fflush.c Tue Jul 06 14:22:16 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fflush.c,v 1.19 2021/07/05 07:26:00 christos Exp $ */
+/* $NetBSD: fflush.c,v 1.20 2021/07/06 14:22:16 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)fflush.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fflush.c,v 1.19 2021/07/05 07:26:00 christos Exp $");
+__RCSID("$NetBSD: fflush.c,v 1.20 2021/07/06 14:22:16 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -107,7 +107,11 @@
for (; n > 0; n -= t, p += t) {
t = (*fp->_write)(fp->_cookie, (char *)p, n);
- if (t <= 0) {
+ if (t < 0) {
+ if (errno == EINTR) {
+ t = 0;
+ continue;
+ }
/* Reset _p and _w. */
if (p > fp->_p) {
/* Some was written. */
diff -r 532c028323d7 -r b121d90d5c65 lib/libc/stdio/fvwrite.c
--- a/lib/libc/stdio/fvwrite.c Tue Jul 06 12:42:12 2021 +0000
+++ b/lib/libc/stdio/fvwrite.c Tue Jul 06 14:22:16 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fvwrite.c,v 1.25 2012/03/27 15:05:42 christos Exp $ */
+/* $NetBSD: fvwrite.c,v 1.26 2021/07/06 14:22:16 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)fvwrite.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: fvwrite.c,v 1.25 2012/03/27 15:05:42 christos Exp $");
+__RCSID("$NetBSD: fvwrite.c,v 1.26 2021/07/06 14:22:16 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -97,15 +97,21 @@
len = iov->iov_len; \
iov++; \
}
+#define WRITE(nw) \
+ w = (*fp->_write)(fp->_cookie, p, nw); \
+ if (w < 0) { \
+ if (errno != EINTR) \
+ goto err; \
+ w = 0; \
+ } else \
+ w = w
if (fp->_flags & __SNBF) {
/*
* Unbuffered: write up to BUFSIZ bytes at a time.
*/
do {
GETIOV(;);
- w = (*fp->_write)(fp->_cookie, p, MIN(len, BUFSIZ));
- if (w <= 0)
- goto err;
+ WRITE(MIN(len, BUFSIZ));
p += w;
len -= w;
} while ((uio->uio_resid -= w) != 0);
@@ -160,9 +166,7 @@
goto err;
} else if (len >= (size_t)(w = fp->_bf._size)) {
/* write directly */
- w = (*fp->_write)(fp->_cookie, p, (size_t)w);
- if (w <= 0)
- goto err;
+ WRITE((size_t)w);
} else {
/* fill and done */
w = len;
@@ -199,9 +203,7 @@
if (fflush(fp))
goto err;
} else if (s >= (w = fp->_bf._size)) {
- w = (*fp->_write)(fp->_cookie, p, (size_t)w);
- if (w <= 0)
- goto err;
+ WRITE((size_t)w);
} else {
w = s;
COPY(w);
Home |
Main Index |
Thread Index |
Old Index