From nobody Sun Jan 07 17:50:35 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4T7Pqc3tz9z55XWj; Sun, 7 Jan 2024 17:50:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T7Pqc1WpRz4MNR; Sun, 7 Jan 2024 17:50:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704649836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DJAhRGdGQsiPc4GA+OouO97AjgQ/oq/oUQ1zlejK/hA=; b=ttrjW9BPBRG0fev0e0r1ADwrFhbH1BAHdaZl32O2/ukBkmGNB6rAHatHRAphdzre7F5lH/ 04Ogt6pnWhhkAHWqxSvdLcuDxCQvMbC6QiE0iNXH6nqDMj9z1RWgSBcK0jvk1OanYTo9bW zyCjZchHkc4+kos2YBUkkEuDyhxlSYZ7VwWVfwkskjV4TOt0frxfZGkIp3Te0oADnjMwKE XYzLO3Pbln/dXyq7K115eNGgWJI2PA4CoaSbd9P+Pud+PxAJ0JvWE0jq1UehbKRiTcOfRW LvIzKj1enyfnvlMdbVEEt57R7L5Q+czSIBCtySaBVNo1O0gEHkO++qGStsmvRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704649836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DJAhRGdGQsiPc4GA+OouO97AjgQ/oq/oUQ1zlejK/hA=; b=IzKoNIeYPuGRT+x5VLsxx3rsR+C3jI+brYY8FDOFbf6DnTku5Ix3YxrPi8EXsevWdM7O15 UJe/q4mhFa0UnhVsllrP3aS+CwhegRb0pt1IJII3+umvASpORMZmEww503fMGtcsm3B340 SKKPcoceSiAaccNqHDfjMbwIxAPnVWn8n8NBhZqAiENFyOIEGUjm39/6TPxrrm+5QWzdmr Oi39AfzVbhellFPcapqsgvyIEsKWKOTtsIUcl2tRL/gNEjIcuEueO64EGMRcRzrf14cLci QRDsTHtuseI9OCNxagZxp0RxzyCKU+KBPBfQkgLWbkDU4i0T+toD+FBK9Poywg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704649836; a=rsa-sha256; cv=none; b=o0N8RIx9E+5Ag1ImN3P3SvyhvSycPKAO4DtVC17oc3yk/7eyZLDEKwyTclMzJMjP5Ze38I iXyJFXJizVmocTCP8eE75686LnVtQTvS5TBVcedxtuCPhHCNFL3JmG5ry3yRbuBFWTGcLy tAJkE7cmGvuJuqrewC8v63pPmC7sMmlDRRh6fJS370Z0hNEow8U18B/NcFOUWxbvJzh/Cq FLsTxoea+k/weaDzYYmZtm6893BGnguOPt2NgVB/wMWzfaGvvPb9tGTNvwtznEOYVuoyYw aaTr+MKyZRHsss8c+MjdqMmf/6hYpMdgNUvgIyXyuxL4xdTRmLh5NMKcMnF3Fg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4T7Pqc0ZhJzZGZ; Sun, 7 Jan 2024 17:50:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 407HoZ2V022374; Sun, 7 Jan 2024 17:50:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 407HoZ5d022371; Sun, 7 Jan 2024 17:50:35 GMT (envelope-from git) Date: Sun, 7 Jan 2024 17:50:35 GMT Message-Id: <202401071750.407HoZ5d022371@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 0c8ebcda1b6d - stable/14 - llvm: Support: don't block signals around close if it can be avoided List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 0c8ebcda1b6d5ae1c65f11f8e70494008205dee8 Auto-Submitted: auto-generated The branch stable/14 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=0c8ebcda1b6d5ae1c65f11f8e70494008205dee8 commit 0c8ebcda1b6d5ae1c65f11f8e70494008205dee8 Author: Mateusz Guzik AuthorDate: 2023-12-29 18:51:56 +0000 Commit: Dimitry Andric CommitDate: 2024-01-07 17:46:19 +0000 llvm: Support: don't block signals around close if it can be avoided Signal blocking originally showed up in 51c2afc4b65b2782 ("Support: Don't call close again if we get EINTR"), but it was overzealous -- there are systems where the error is known to be fine. This commit elides signal blocking for said systems (the list is incomplete though). Note close() can still fail for other reasons (like ENOSPC), in which case an error will be returned while the fd slot is cleared up. Reviewed by: dim Differential Revision: https://reviews.freebsd.org/D42984 (cherry picked from commit 3358108a38f0efc7e7a143aeda80c941946fef77) --- .../llvm-project/llvm/lib/Support/Unix/Process.inc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/contrib/llvm-project/llvm/lib/Support/Unix/Process.inc b/contrib/llvm-project/llvm/lib/Support/Unix/Process.inc index 2babf07944bf..c8b15cb759df 100644 --- a/contrib/llvm-project/llvm/lib/Support/Unix/Process.inc +++ b/contrib/llvm-project/llvm/lib/Support/Unix/Process.inc @@ -235,6 +235,25 @@ std::error_code Process::FixupStandardFileDescriptors() { return std::error_code(); } +// Close a file descriptor while being mindful of EINTR. +// +// On Unix systems closing a file descriptor usually starts with removing it +// from the fd table (or an equivalent structure). This means any error +// generated past that point will still result in the entry being cleared. +// +// Make sure to not bubble up EINTR as there is nothing to do in that case. +// XXX what about other errors? +#if defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) || \ + defined(__NetBSD__) || defined(__OpenBSD__) +std::error_code Process::SafelyCloseFileDescriptor(int FD) { + int EC = 0; + if (::close(FD) < 0) { + if (errno != EINTR) + EC = errno; + } + return std::error_code(EC, std::generic_category()); +} +#else std::error_code Process::SafelyCloseFileDescriptor(int FD) { // Create a signal set filled with *all* signals. sigset_t FullSet, SavedSet; @@ -269,6 +288,7 @@ std::error_code Process::SafelyCloseFileDescriptor(int FD) { return std::error_code(ErrnoFromClose, std::generic_category()); return std::error_code(EC, std::generic_category()); } +#endif bool Process::StandardInIsUserInput() { return FileDescriptorIsDisplayed(STDIN_FILENO);