git: 945e60e018c2 - main - diff3: set O_CLOEXEC on pipes
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 28 Mar 2026 08:56:35 UTC
The branch main has been updated by bapt:
URL: https://cgit.FreeBSD.org/src/commit/?id=945e60e018c287f8097f3ee4a30ccf4921845aa1
commit 945e60e018c287f8097f3ee4a30ccf4921845aa1
Author: Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2026-03-28 08:41:47 +0000
Commit: Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2026-03-28 08:51:48 +0000
diff3: set O_CLOEXEC on pipes
This avoid leaking pipe fd in children and simplifies the code
MFC After: 1 week
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D56120
---
usr.bin/diff3/diff3.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/usr.bin/diff3/diff3.c b/usr.bin/diff3/diff3.c
index 8212b51e15a2..bbef1f0d21a5 100644
--- a/usr.bin/diff3/diff3.c
+++ b/usr.bin/diff3/diff3.c
@@ -317,10 +317,7 @@ diffexec(char **diffargv, int fd[])
errc(2, error, "posix_spawn_file_actions_init");
posix_spawnattr_setprocdescp_np(&sa, &pd, 0);
-
- posix_spawn_file_actions_addclose(&fa, fd[0]);
posix_spawn_file_actions_adddup2(&fa, fd[1], STDOUT_FILENO);
- posix_spawn_file_actions_addclose(&fa, fd[1]);
error = posix_spawn(&pid, diffargv[0], &fa, &sa, diffargv, environ);
if (error != 0)
@@ -1085,12 +1082,11 @@ main(int argc, char **argv)
if (caph_rights_limit(fileno(fp[2]), &rights_ro) < 0)
err(2, "unable to limit rights on: %s", file3);
- if (pipe(fd13))
+ if (pipe2(fd13, O_CLOEXEC))
err(2, "pipe");
- if (pipe(fd23))
+ if (pipe2(fd23, O_CLOEXEC))
err(2, "pipe");
-
diffargv[diffargc] = file1;
diffargv[diffargc + 1] = file3;
diffargv[diffargc + 2] = NULL;