Module Name: src
Committed By: christos
Date: Sun May 19 17:07:05 UTC 2013
Modified Files:
src/lib/libc/stdio: stdio.c
Log Message:
from kre: Don't fail if we are seeking on a pipe, clear the append bit
since we always append.
To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libc/stdio/stdio.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/stdio/stdio.c
diff -u src/lib/libc/stdio/stdio.c:1.21 src/lib/libc/stdio/stdio.c:1.22
--- src/lib/libc/stdio/stdio.c:1.21 Tue Mar 27 11:05:42 2012
+++ src/lib/libc/stdio/stdio.c Sun May 19 13:07:04 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: stdio.c,v 1.21 2012/03/27 15:05:42 christos Exp $ */
+/* $NetBSD: stdio.c,v 1.22 2013/05/19 17:07:04 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)stdio.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: stdio.c,v 1.21 2012/03/27 15:05:42 christos Exp $");
+__RCSID("$NetBSD: stdio.c,v 1.22 2013/05/19 17:07:04 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -86,8 +86,12 @@ __swrite(void *cookie, const void *buf,
_DIAGASSERT(buf != NULL);
if (fp->_flags & __SAPP)
- if (lseek(__sfileno(fp), (off_t)0, SEEK_END) == (off_t)-1)
- return -1;
+ if (lseek(__sfileno(fp), (off_t)0, SEEK_END) == (off_t)-1) {
+ if (errno == ESPIPE) /* if unseekable, OK, */
+ fp->_flags &= ~__SAPP; /* all writes append. */
+ else
+ return -1;
+ }
fp->_flags &= ~__SOFF; /* in case FAPPEND mode is set */
return write(__sfileno(fp), buf, n);
}