Subject: Re: [PATCH v8 09/12] run-command: add close_fd_above_stderr option

From: Junio C Hamano <[email-masked]>
Date: Wed, 04 Mar 2026 20:13:43 -0800

Paul Tarjan <[email-masked]> writes:

> On Wed, Mar 4, 2026, Junio C Hamano wrote:
>> I wonder if a generic callback function
>> to call here in the child between fork and exec that the caller can
>> supply would be a good thing to have.
>
> Done in v9. Replaced the close_fd_above_stderr flag with a pre_exec_cb
> function pointer on struct child_process. The fd-closing logic is now
> a standalone close_fd_above_stderr() function that the two fsmonitor
> callers pass as the callback.

I didn't mean to suggest using a generic mechanism to _replace_ what
you added.

A truly generic callback mechanism that will be useful can and
should wait until we see real use cases for one.

And I strongly suspect that the callback would want to take some
callback data argument, not "void cb(void)", but more like "int
cb(void *)" (we may find a return value that lets us tell the
run_command() to abort instead of exec(2)ingg, for example---and we
can make a better design when we do have real use cases.