git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Fix start_command closing cmd->out/in regardless of cmd->close_out/in

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Nov 20, 2007, 16:17 UTC
Message-ID
<474308A5.8070301@viscovery.net>
In-Reply-To
<1195503174-29387-1-git-send-email-pkufranky@gmail.com>
Ping Yin schrieb:
> This patch disables the auto closing behavious of start_command
> and corrects all codes which depend on this kind of behaviour.

I've thought about this a bit more, and I think that it is better to leave this auto-closing behavior unchanged and change your usage of this feature, like so:

Show 6 quoted lines
> +static void wt_status_print_submodule_summary(struct wt_status *s)
> +{
> +       struct child_process sm_summary;
> +       memset(&sm_summary, 0, sizeof(sm_summary));
> +       ...
> +       sm_summary.out = fileno(s->fp);
	fflush(s->fp);
	sm_summary.out = dup(fileno(s->fp));	/* run_command closes it */
> +       ...
> +       run_command(&sm_summary);
> +}
This way the change is more local without affecting well-tested other callers.

Furthermore, I don't think that it's correct to just set the .close_in or .close_out flags. This will close the fd only in finish_command(), which can be too late: Think again of a writable pipe end that remains open and keeps the reader waiting for input that is not going to happen.

-- Hannes
Previous: Ping YinNext: Ping Yin
Message 2 of 5 in “Fix start_command closing cmd->out/in regardless of cmd->close_out/in”
  1. Fix start_command closing cmd->out/in regardless of cmd->close_out/inPing Yin, Nov 19, 2007
  2. Johannes SixtNov 20, 2007
  3. Ping YinNov 21, 2007
  4. Junio C HamanoNov 21, 2007
  5. Ping YinNov 21, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.