From nobody Fri Dec 15 18:57:30 2023 X-Original-To: dev-commits-src-branches@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 4SsJPQ4sgqz53wqK; Fri, 15 Dec 2023 18:57:30 +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 4SsJPQ4BCBz3MKW; Fri, 15 Dec 2023 18:57:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1702666650; 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=pXGbr8N5tUbV1/HkYxDgeKHANPPKcdn8uq6U4e4jIWY=; b=c/AiH/eOKkNrm4DjsEaVOQXVYRg1SJ9Gtloig4c4d296MLO0efHIhdb5klYy+AZrAnIEyb pVWNfalumwNzV6f3Agz6TPJw0FY4zdVMozTjB/Zd5UaTQctDked/acws7zO6C8wLYuOsAv MYcJXA5cW9TiuzaUkeroV1R/3nBGL2ako51LY98vdIJz+SKkvDv1TSeZZWs4gcsPuuNzUR WoMSVCsYinWxcGH2llpEh5ZD//Vi/BMGI0lO49suvf9tsXd5wSqdr4PC8pKkW8K8ruDons DMcaNcV4rJCQ3fNTunqghIfJqbUARI+CPq0zRj1UHllsjIwyeuyZJj1YOugnjA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1702666650; a=rsa-sha256; cv=none; b=kwLinlT/chMmS7Zb7fmRzIwE/rGMmr+5lC7ysIjkJnQS0Kt5XUPmGgyouF0xpLBAL5nBLn o3DASe1FULLYod6dGs3TjF0W912osjwi8dk+PnndWNUyI3+oWLr4ueYEAXI/Sk4tLHrx9b IR/A9xQEosC6QUoLQUIps6lobYlKIre/R56CQ4t15Y0HJKi+UTlyBbnlZXeyoxxT38eEcp IR/tJaYVx8PbrGIeQznZVwRfHN4gcjhEzsArRwSDv1zULaEuIuOGucrH7gPzq5eemV4l1M UFtaQb1nd/5KrsO1q70Uw7sG9lkmLUFn0euV6Wy1C1c/K/E5+SOSULM+m5JVOQ== 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=1702666650; 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=pXGbr8N5tUbV1/HkYxDgeKHANPPKcdn8uq6U4e4jIWY=; b=P/VNLpItBKaJu0bniUAN1otssH5eSjLtdS3W4QGK9xhJBPngcifwxK9G+bp6cjspVks/VT CYALW3ZH+AAT3KlI7/0KSe1dH1dEUMg+GxSKoSvvVhtoBYPS2mU0xS8qfnIOwuMenl2jHT 6EhwZeVP9rQqfkASA15lHYn86e07gSrEt4jtIpmaqelYR+CsBwFOdUe9x65lY3vywOb7Rd M5xhLI0EKdHmVMGpLL/+CdBHTDqXv3WbpQxfQDIazGXDzDe/GW0vrCFr1EC/QpY+yaLcT7 w/Oqq0DtEXZ3kFg6KSOe6P4XEgSRzWRLg26uUXBNj3kZBck++I23aXaBJMll2g== 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 4SsJPQ36Nyz7fW; Fri, 15 Dec 2023 18:57:30 +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 3BFIvUEp018308; Fri, 15 Dec 2023 18:57:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BFIvUUo018305; Fri, 15 Dec 2023 18:57:30 GMT (envelope-from git) Date: Fri, 15 Dec 2023 18:57:30 GMT Message-Id: <202312151857.3BFIvUUo018305@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 159d922f4ce9 - stable/13 - lockf: don't hold stdin/stdout/stderr open List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 159d922f4ce9405189b4f92bfe46858bfde75400 Auto-Submitted: auto-generated The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=159d922f4ce9405189b4f92bfe46858bfde75400 commit 159d922f4ce9405189b4f92bfe46858bfde75400 Author: Alexander Melkov AuthorDate: 2023-11-22 04:46:28 +0000 Commit: Kyle Evans CommitDate: 2023-12-15 00:59:18 +0000 lockf: don't hold stdin/stdout/stderr open None of these are essential in the lockf monitor (parent post-fork), so close them to maintain the illusion that lockf hasn't been inserted into the pipeline. This ensures that the correct effects happen on other programs in the pipeline if the locked command closes or redirects these elsewhere. The original patch used -s to close stdout/stderr rather than closing them unconditionally, but it's not clear that we really care that much. kevans dropped that part when taking the patch, patch is otherwise by listed author. PR: 112379 Reviewed by: 0mp, allanjude (both earlier version), kevans Feedback from: des Sponsored by: Klara, Inc. (cherry picked from commit 18425c19cae08cbe41801845457ed67285806688) --- usr.bin/lockf/lockf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.bin/lockf/lockf.c b/usr.bin/lockf/lockf.c index 8b0a13e3ca0f..1149128021e6 100644 --- a/usr.bin/lockf/lockf.c +++ b/usr.bin/lockf/lockf.c @@ -157,8 +157,11 @@ main(int argc, char **argv) signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); signal(SIGTERM, killed); + fclose(stdin); + fclose(stdout); + fclose(stderr); if (waitpid(child, &status, 0) == -1) - err(EX_OSERR, "waitpid failed"); + exit(EX_OSERR); return (WIFEXITED(status) ? WEXITSTATUS(status) : EX_SOFTWARE); } @@ -210,7 +213,7 @@ killed(int sig) cleanup(); signal(sig, SIG_DFL); if (kill(getpid(), sig) == -1) - err(EX_OSERR, "kill failed"); + _Exit(EX_OSERR); } /*