From nobody Fri Dec 29 19:13:47 2023 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 4T1w5l5WRhz551wg; Fri, 29 Dec 2023 19:13:47 +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 4T1w5l51Kxz3JFl; Fri, 29 Dec 2023 19:13:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703877227; 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=F8q5Jh/QnA6lCYy7H5BrL4n/nGuqfc6KVs4/vSzhqdg=; b=bUSRB3OvmWR5T0o23kPLC7AJbWKUnwFyYrC5hoNMT4671LbzPTPc2eIY7zo+QhaNV5WtkH A0R9P+feRwJgTiW6sxMwe0uxAoUMmoLop0XNp+Lgi/ViRRLYR2vPOMwn0REsninr56DdUu tSXvd3aUFf83V/EixDtbtZhjfY4OvoX1KBQFiHb0MoDHSliL6cXpKulJDajVPMLcHp56Kr HM0SnDNsZ5LaYUaju3QoUeRqGpLamG6uULnjtemetIYB2qddPcW/H8YYh2+yK2Vg2vu/1A CcBFK+RIIhTKY1DdRE0lU31yYGUNCoICFUYQocJc11ZdQsHewdEgBm5G0MppdA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703877227; a=rsa-sha256; cv=none; b=GQw0WFaeTZvZnOtXdrm+FcOZFVtWmbQJ6GzBwq22/MZZG2LqXHrG+fmIYwBIVC2tKoO+34 t66Syqk93EVExwL4zY3PmX/KEGmMKBdIPZfOs0LGeJqRbSnSBz9oTJg/ts/XG6G4U+ovRS 3BjeSxLPUfAnSkoYgsT5UTYmKQwo7+j9Wf2nQRsvb+CkUiMcBRN59iQVYUrhGUVOTopdiT xDty+dfu5x4oDecoGMDYAKkjGg0yygvEkgzESTxyFDEDVwMdvhMWINi24uIAQZZo5fwunF R7Rebi2PqnXJuPvDdZKz2hmX6cYymOyuKDea2TE6YA/1cjP9CPTGslAoJWXLpw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703877227; 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=F8q5Jh/QnA6lCYy7H5BrL4n/nGuqfc6KVs4/vSzhqdg=; b=oCtAhAp5LrIDXx89PCmf89+aWkLw2dQuFYBR05l43fTzhj3svlKDzMls4yV4SCuXkRtLLh 9rGdoEohwSyM7cKAHezWib3zUKOz9GLLd6lOsOQXFo+MDYllky+YvOIaHmPlmjmT+CBSuN ALh/BPRhmAAqVBDll+xye+7kGVpZhhoGyJxCrzxZiVajYrNNu5AbD/1gWiYluWNfPDSyQP +EeXt/7IEkZNIXCHbp/nmlhv834I/E1kRVKdx6r8Fsbwf7zHQKXisvTntSfRuQGkdmMnct Cb+m3IMjCPTI/4e3CktodOBsgEXvP+UN4NOr8hajSxIsshHnHXJSG0P5+ZoBXA== 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 4T1w5l43fvz3kF; Fri, 29 Dec 2023 19:13:47 +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 3BTJDlZu087295; Fri, 29 Dec 2023 19:13:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BTJDl3L087292; Fri, 29 Dec 2023 19:13:47 GMT (envelope-from git) Date: Fri, 29 Dec 2023 19:13:47 GMT Message-Id: <202312291913.3BTJDl3L087292@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 3358108a38f0 - main - 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: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3358108a38f0efc7e7a143aeda80c941946fef77 Auto-Submitted: auto-generated The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=3358108a38f0efc7e7a143aeda80c941946fef77 commit 3358108a38f0efc7e7a143aeda80c941946fef77 Author: Mateusz Guzik AuthorDate: 2023-12-29 18:51:56 +0000 Commit: Mateusz Guzik CommitDate: 2023-12-29 18:52:12 +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 --- .../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);