git: 44cf1e5eb470 - main - libc/stdio: only roll FILE state back on EINTR
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 03 Sep 2022 01:16:26 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=44cf1e5eb470380442fa8e240e213a71b8fe81d4 commit 44cf1e5eb470380442fa8e240e213a71b8fe81d4 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-09-02 13:39:38 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-09-03 01:06:41 +0000 libc/stdio: only roll FILE state back on EINTR Reported by: JunT <takimoto-j@kba.biglobe.ne.jp> PR: 266171 Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D36427 --- lib/libc/stdio/fflush.c | 3 ++- lib/libc/stdio/fvwrite.c | 5 +++-- lib/libc/stdio/wbuf.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/libc/stdio/fflush.c b/lib/libc/stdio/fflush.c index decc974907f4..f59565abd369 100644 --- a/lib/libc/stdio/fflush.c +++ b/lib/libc/stdio/fflush.c @@ -136,7 +136,8 @@ __sflush(FILE *fp) fp->_p += n; if ((fp->_flags & (__SLBF | __SNBF)) == 0) fp->_w -= n; - } else if (p == fp->_p) { /* cond. to handle setvbuf */ + /* conditional to handle setvbuf */ + } else if (p == fp->_p && errno == EINTR) { fp->_p = old_p; fp->_w = old_w; } diff --git a/lib/libc/stdio/fvwrite.c b/lib/libc/stdio/fvwrite.c index 2a161859afa9..b1b363e6f80d 100644 --- a/lib/libc/stdio/fvwrite.c +++ b/lib/libc/stdio/fvwrite.c @@ -38,6 +38,7 @@ static char sccsid[] = "@(#)fvwrite.c 8.1 (Berkeley) 6/4/93"; #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -140,7 +141,7 @@ __sfvwrite(FILE *fp, struct __suio *uio) fp->_p += w; old_p = fp->_p; if (__fflush(fp) == EOF) { - if (old_p == fp->_p) + if (old_p == fp->_p && errno == EINTR) fp->_p -= w; goto err; } @@ -184,7 +185,7 @@ __sfvwrite(FILE *fp, struct __suio *uio) fp->_p += w; old_p = fp->_p; if (__fflush(fp) == EOF) { - if (old_p == fp->_p) + if (old_p == fp->_p && errno == EINTR) fp->_p -= w; goto err; } diff --git a/lib/libc/stdio/wbuf.c b/lib/libc/stdio/wbuf.c index d389cdab0353..666bbf87aadd 100644 --- a/lib/libc/stdio/wbuf.c +++ b/lib/libc/stdio/wbuf.c @@ -91,7 +91,7 @@ __swbuf(int c, FILE *fp) old_p = fp->_p; if (++n == fp->_bf._size || (fp->_flags & __SLBF && c == '\n')) { if (__fflush(fp) != 0) { - if (fp->_p == old_p) { + if (fp->_p == old_p && errno == EINTR) { fp->_p--; fp->_w++; }