tech-userlevel archive

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

Re: Incompat change (6 weeks ago) in stdio breaks formail (from procmail)

    Date:        Sun, 19 May 2013 02:56:06 +0000
    From:        David Holland <>
    Message-ID:  <>

  | I'd vote for explicitly testing for ESPIPE; it's the Right Thing (tm).

When I started sending the previous message, that was how I had expected
it to end - I even had a patch prepared which does that, which I had
intended including.   By the time I finished the message, I had pretty
much convinced myself that the simplicity of just ignoring the error
(and leaving the code the way it has been for a long long time) was
better, so, I didn't bother including the patch in the message.

But, here it is, in case others decide this is the better way.   I think
the problem needs to be fixed, one way or the other - I am not a developer,
so I don't get a vote, and either change works OK for me.


Index: stdio.c
RCS file: /cvsroot/NetBSD/src/lib/libc/stdio/stdio.c,v
retrieving revision 1.21
diff -u -r1.21 stdio.c
--- stdio.c     27 Mar 2012 15:05:42 -0000      1.21
+++ stdio.c     19 May 2013 01:40:55 -0000
@@ -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