]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
include/closestream: don't wipe errno on EPIPE
authorKarel Zak <kzak@redhat.com>
Thu, 13 Mar 2014 11:41:03 +0000 (12:41 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 13 Mar 2014 11:41:03 +0000 (12:41 +0100)
... the code in close_stdout() is sensitive to EPIPE, so
wipe errno is close_stream() is probably bad idea.

Signed-off-by: Karel Zak <kzak@redhat.com>
include/closestream.h

index 2535c8b22eb1cbc8b8c76d31297e50b2421ba465..7842456fbac0201d84896c45ccc078cf16409371 100644 (file)
@@ -24,8 +24,9 @@ close_stream(FILE * stream)
        const int some_pending = (__fpending(stream) != 0);
        const int prev_fail = (ferror(stream) != 0);
        const int fclose_fail = (fclose(stream) != 0);
+
        if (prev_fail || (fclose_fail && (some_pending || errno != EBADF))) {
-               if (!fclose_fail)
+               if (!fclose_fail && !(errno == EPIPE))
                        errno = 0;
                return EOF;
        }