From nobody Sun Jan 07 23:08:36 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 4T7XtX5fXYz56F6b; Sun, 7 Jan 2024 23:08: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 4T7XtX4ZMnz4QQ2; Sun, 7 Jan 2024 23:08:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704668916; 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=nqhZvMiiw0AJyyUqvGTtY0j5M9k6n4MfntJlsM+4ZxQ=; b=RQ84GWAVKZyBRzbVMDdn+NRuCynSGLFxVtzjdr+gXZufArwMY1Bg/9H9apkK9OsMM/XdVO l9y6/L1ZKlMotW82bEJkfpDCDgjiOBSf70Z29aebgPTjUWXykXabhrIovnULjcS+D5nHbc zEJo0mJevYhztNWhcoUicjdBsVzMFnxEhUiv4es1IxOaCFbK2G9alN8NOvbcWzS2orl1y9 zLPCS/JTe5h0mxuCdtgxVy1OKFtimq/9KrbAUeaYH9hZ24a3lQvztvlmvU5lNv4mYRaDou WOTqNn+t1hQrCaLWb3xyJcaEuq2EYMdlYEMQYObYRnDkbX2Vq3SjLrAfUYYp9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704668916; 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=nqhZvMiiw0AJyyUqvGTtY0j5M9k6n4MfntJlsM+4ZxQ=; b=Bq6xhWKXIurAta0qj4PL6+ax4ALB8etJ/Rqea1ZG++DVQfOfVCvM4PPuL2D1TxPFjw5kc4 ZxgibKT0kOSz1m1rR7Lnp8VNHXFV/JRkcLDnHkwCU+rlNlDOmnDhNcQAUJ//MeirXWMfId u6IMHltfNi4H49Q0lKU5xGpwMKtuOfGwvKS7HCtupM23uW0bfVCdAyeyEM2lxA4rxLcGxb AJUvRmj6ge+ZUvTbcTWhrXDpvSkmywolXivS1v2xoMlbqGGfqJKJwi/HUXrx0HTY/jaXhs Kb4sMMnTN0Riz7l2JQUJb/KRbmY433tOc3tm5iKvHtlLx+bk6YBLkYidnEC4ZA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704668916; a=rsa-sha256; cv=none; b=L6KuG3GsXqbziaFsEeEcUzEqy8j3f6Osx6WTkKZlNH7oHzlSCa4QX9UYjftv/NxXCU/p1+ 1OItQzdN2R7R4q+cIKKwzTec+LEVRF2LHTYoyZ7htb3cRWeSSJE9h60193cFWS7IcwQWto VH62TK08Am0Ix/HnBaNTBRdnX/YRP6EUn1zqtO5+XL6zWOdUf2P90cvMakwecWzKUDpky3 iHW7JAybuHMZKvYqm2lt2Upqwv8hxnLfi3sYam/c5bhlRmsIG0PLomI7sgWfgFjnNxnPQ/ chvJO+XAzUXCTCF8n9BNAMSMAE/8/cjkpH4DOXgVSRbqTpt2vxF0syCNjyOO6Q== 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 4T7XtX3dDCzk9w; Sun, 7 Jan 2024 23:08: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 407N8aAu053622; Sun, 7 Jan 2024 23:08:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 407N8adP053619; Sun, 7 Jan 2024 23:08:36 GMT (envelope-from git) Date: Sun, 7 Jan 2024 23:08:36 GMT Message-Id: <202401072308.407N8adP053619@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: 7a658756b2a5 - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 7a658756b2a5ceaeb1da3ff1a3cb3760f3792ce4 Auto-Submitted: auto-generated The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=7a658756b2a5ceaeb1da3ff1a3cb3760f3792ce4 commit 7a658756b2a5ceaeb1da3ff1a3cb3760f3792ce4 Author: Mateusz Guzik AuthorDate: 2023-12-29 18:51:56 +0000 Commit: Dimitry Andric CommitDate: 2024-01-07 23:04:43 +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);