From 3e473b9f37920fdb358d597eaf401d36879debb9 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Tue, 13 Apr 2021 10:38:17 +0200 Subject: [PATCH] io: Silence write error with EPIPE With something like ``` history | head -n 1 ``` this would error "write: Broken pipe", which is just annoying. There is no *problem* here, `head` closes this on purpose. Fixes #7924. --- src/io.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/io.cpp b/src/io.cpp index 8529a8594..7d291d390 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -306,7 +306,9 @@ void fd_output_stream_t::append(const wchar_t *s, size_t amt) { int res = wwrite_to_fd(s, amt, this->fd_); if (res < 0) { // TODO: this error is too aggressive, e.g. if we got SIGINT we should not complain. - wperror(L"write"); + if (errno != EPIPE) { + wperror(L"write"); + } errored_ = true; } }