Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/stdio from kre: Don't fail if we are seeking on a p...



details:   https://anonhg.NetBSD.org/src/rev/0634423a6da4
branches:  trunk
changeset: 786899:0634423a6da4
user:      christos <christos%NetBSD.org@localhost>
date:      Sun May 19 17:07:04 2013 +0000

description:
from kre: Don't fail if we are seeking on a pipe, clear the append bit
since we always append.

diffstat:

 lib/libc/stdio/stdio.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (33 lines):

diff -r c8b1b6d41e4c -r 0634423a6da4 lib/libc/stdio/stdio.c
--- a/lib/libc/stdio/stdio.c    Sun May 19 16:53:58 2013 +0000
+++ b/lib/libc/stdio/stdio.c    Sun May 19 17:07:04 2013 +0000
@@ -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 @@
        _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);
 }



Home | Main Index | Thread Index | Old Index