]> git.saurik.com Git - apple/libc.git/blob - stdio/FreeBSD/fflush.c.patch
Libc-763.11.tar.gz
[apple/libc.git] / stdio / FreeBSD / fflush.c.patch
1 --- fflush.c.bsdnew 2009-11-11 13:33:04.000000000 -0800
2 +++ fflush.c 2009-11-11 13:33:04.000000000 -0800
3 @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD: src/lib/libc/stdio/f
4 #include "namespace.h"
5 #include <errno.h>
6 #include <stdio.h>
7 +#include <string.h>
8 #include "un-namespace.h"
9 #include "libc_private.h"
10 #include "local.h"
11 @@ -122,6 +123,14 @@ __sflush(FILE *fp)
12 for (; n > 0; n -= t, p += t) {
13 t = _swrite(fp, (char *)p, n);
14 if (t <= 0) {
15 + /* 5340694: reset _p and _w on EAGAIN */
16 + if (t < 0 && errno == EAGAIN) {
17 + if (p > fp->_p) /* some was written */
18 + memmove(fp->_p, p, n);
19 + fp->_p += n;
20 + if (!(fp->_flags & (__SLBF|__SNBF)))
21 + fp->_w -= n;
22 + }
23 fp->_flags |= __SERR;
24 return (EOF);
25 }