From ca61fc1bf8bd6bf3957ad709dfcb9becdc572e37 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Wed, 5 Sep 2018 21:48:32 -0700 Subject: [PATCH] Stop retrying close() on EINTR https://lwn.net/Articles/576478/ http://austingroupbugs.net/view.php?id=529 https://sourceware.org/bugzilla/show_bug.cgi?id=14627 --- src/common.cpp | 7 ++----- src/exec.cpp | 8 +++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/common.cpp b/src/common.cpp index 334fd6011..df3b68359 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -2010,11 +2010,8 @@ void convert_wide_array_to_narrow(const null_terminated_array_t &wide_a void autoclose_fd_t::close() { if (fd_ < 0) return; - while (::close(fd_) == -1) { - if (errno != EINTR) { - wperror(L"close"); - break; - } + if (::close(fd_) == -1) { + wperror(L"close"); } fd_ = -1; } diff --git a/src/exec.cpp b/src/exec.cpp index 672331221..957c7fbb1 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -73,11 +73,9 @@ void exec_close(int fd) { } while (close(fd) == -1) { - if (errno != EINTR) { - debug(1, FD_ERROR, fd); - wperror(L"close"); - break; - } + debug(1, FD_ERROR, fd); + wperror(L"close"); + break; } }