From nobody Sun Nov 26 04:10:50 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 4SdFd65rMhz52lJt; Sun, 26 Nov 2023 04:10:50 +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 4SdFd64TmXz3KSl; Sun, 26 Nov 2023 04:10:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700971850; 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=kisFp+h1tIU03LhcjbFQBS3C638ElFQjiCnBaGXFyJ8=; b=ngv15GQadaJVA/N1f2TfgG36213Jvc0tqqmxkaD50/PTiuXShlTRV3Ni9yodhmQOUEZnep pQDeHasON1N2vodav/CaP9LyRt2LhwEDd1Y3Y7DnmBmj4FBEHuPUemglgQ5Fp237wzYqmE xN2Aw0smUF2GT/ujWZhhryY7smfabr4kcG7aoBo96pckzBNivRJCnADP9syx7R2UcsSeQ6 7hdKnbw6wuecdIE+6mT0+cJb6IsYWrcv08hsQ9d30XkwiiLQLTcRZS+Hc795TTW+qrtxhN AvO4pZtyLpOvX5kumu1ZdGKhryqESsxbiMkbog2+UPJ72zdpl6oRvYwyBybLyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700971850; 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=kisFp+h1tIU03LhcjbFQBS3C638ElFQjiCnBaGXFyJ8=; b=JsvFbSCajRrqI/OV6OLY2ggNJ/Xi7vlTZQQWR/Tklr3rXYdxcRUkrOEAUuV5oUPq7UTjC7 A3eRgzlVHMeHIz0NCO8cmqwtbIlSzopvlE2JlZo+0J94cKZ1Hu0y5NBEj2xgQT50YeHha9 Wfn0J+P1inWHf1ainHr4362YLdRfb/y+iJ01MeNSBZcaZDR/so25Hj+SvaM7PTG2kyp+nU vzaQ7teb+ZCVVzTs3qi4lUDPvRqKpkk4C1teUnaHW9j0y7+E+vyzDx+WCo82+EYMJ16VuW hprMy+lMQInIupso0rXNkP/PSf4LA7Zlj1xwJld7hs83fdM20LetsfdmWKyJVg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700971850; a=rsa-sha256; cv=none; b=Y+pTwDfrwZsZotQp7024FeIysU/gD0IUARQEMlxD47CMMfvqHt+Te2wGmBvkKB7on4dKds fXIlfrr+RnoiKNUE1pIq4QpvKHLif6QwmV4+uF5/9+XAoC32O3Po/fGgAr0lr663xGGtBt DST1Fz3cTalaUI6JI63OjPPT1tsppdYAM47cQ+sdNGZQkVkkrwwhLXGIbTzAdOfWP2/NRT mVhlyanLozSg2vnE14IEBQqRg+WDba5oO4+o/kiARAT/jF/8BxSPER4t4+RQ3PhuTykhN4 PMZeVotdzsHV4MhRmPF6+v+03+shH3AWF23lFWZJQ4AhPHtcQ5CLKfWJ4pNjPA== 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 4SdFd62Y9rzgPM; Sun, 26 Nov 2023 04:10:50 +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 3AQ4Aoj5038115; Sun, 26 Nov 2023 04:10:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AQ4Ao3B038112; Sun, 26 Nov 2023 04:10:50 GMT (envelope-from git) Date: Sun, 26 Nov 2023 04:10:50 GMT Message-Id: <202311260410.3AQ4Ao3B038112@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 18425c19cae0 - main - lockf: don't hold stdin/stdout/stderr open 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: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 18425c19cae08cbe41801845457ed67285806688 Auto-Submitted: auto-generated The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=18425c19cae08cbe41801845457ed67285806688 commit 18425c19cae08cbe41801845457ed67285806688 Author: Alexander Melkov AuthorDate: 2023-11-22 04:46:28 +0000 Commit: Kyle Evans CommitDate: 2023-11-26 04:09:27 +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. Differential Revision: https://reviews.freebsd.org/D42713 --- 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 ff1e7a6d6216..620193cba1d7 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); } /*