Date: Fri, 15 Dec 2023 18:57:30 GMT From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 159d922f4ce9 - stable/13 - lockf: don't hold stdin/stdout/stderr open Message-ID: <202312151857.3BFIvUUo018305@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=159d922f4ce9405189b4f92bfe46858bfde75400 commit 159d922f4ce9405189b4f92bfe46858bfde75400 Author: Alexander Melkov <melkov@comptek.ru> AuthorDate: 2023-11-22 04:46:28 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> 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); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202312151857.3BFIvUUo018305>