Subject: [RFC PATCH 1/2] run-command: add a pipe() write end to childs

From: Carlo Marcelo Arenas Belón <[email-masked]>
Date: Thu, 26 Jun 2025 14:22:33 -0700

Instruct the child to close the read side of a pipe provided by
the parent for notification that would be used in a future patch.

Signed-off-by: Carlo Marcelo Arenas Belón <[email-masked]>
---
 run-command.c | 3 +++
 run-command.h | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/run-command.c b/run-command.c
index 8833b23367..0156d3a01d 100644
--- a/run-command.c
+++ b/run-command.c
@@ -796,6 +796,9 @@ int start_command(struct child_process *cmd)
 		set_error_routine(child_error_fn);
 		set_warn_routine(child_warn_fn);
 
+		if (cmd->parent_ipc_in != -1)
+			close(cmd->parent_ipc_in);
+
 		close(notify_pipe[0]);
 		set_cloexec(notify_pipe[1]);
 		child_notifier = notify_pipe[1];
diff --git a/run-command.h b/run-command.h
index 0df25e445f..d731b400b9 100644
--- a/run-command.h
+++ b/run-command.h
@@ -81,6 +81,7 @@ struct child_process {
 	const char *trace2_child_class;
 	const char *trace2_hook_name;
 
+	int parent_ipc_in;
 	/*
 	 * Using .in, .out, .err:
 	 * - Specify 0 for no redirections. No new file descriptor is allocated.
@@ -147,6 +148,7 @@ struct child_process {
 #define CHILD_PROCESS_INIT { \
 	.args = STRVEC_INIT, \
 	.env = STRVEC_INIT, \
+	.parent_ipc_in = -1, \
 }
 
 /**
-- 
2.39.5 (Apple Git-154)