diff options
| author | Colin Percival <cperciva@FreeBSD.org> | 2004-07-04 20:17:00 +0000 |
|---|---|---|
| committer | Colin Percival <cperciva@FreeBSD.org> | 2004-07-04 20:17:00 +0000 |
| commit | 0a31135d110ced0f330e510c097107fcc13d55d1 (patch) | |
| tree | 776d8f813467ff38018ce69eeff746069b249c18 /lib/libc | |
| parent | decbf84ef3797ffacb67bbcaf61f013855832447 (diff) | |
Notes
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/stdio/fflush.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/libc/stdio/fflush.c b/lib/libc/stdio/fflush.c index eb40d69eea179..3090dc96d532c 100644 --- a/lib/libc/stdio/fflush.c +++ b/lib/libc/stdio/fflush.c @@ -61,6 +61,18 @@ fflush(FILE *fp) if (fp == NULL) return (_fwalk(sflush_locked)); FLOCKFILE(fp); + + /* + * There is disagreement about the correct behaviour of fflush() + * when passed a file which is not open for reading. According to + * the ISO C standard, the behaviour is undefined. + * Under linux, such an fflush returns success and has no effect; + * under Windows, such an fflush is documented as behaving instead + * as fpurge(). + * Given that applications may be written with the expectation of + * either of these two behaviours, the only safe (non-astonishing) + * option is to return EBADF and ask that applications be fixed. + */ if ((fp->_flags & (__SWR | __SRW)) == 0) { errno = EBADF; retval = EOF; |
