Re: [PATCH v8 09/12] run-command: add close_fd_above_stderr option
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 5, 2026, 04:13 UTC
- Message-ID
- <xmqqv7fa52x4.fsf@gitster.g>
- In-Reply-To
- <20260305004959.83647-1-github@paulisageek.com>
Paul Tarjan <paul@paultarjan.com> writes:
Show 9 quoted lines
> 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.