All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Sixt <j.sixt@viscovery.net>
To: Ping Yin <pkufranky@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Fix start_command closing cmd->out/in regardless of cmd->close_out/in
Date: Tue, 20 Nov 2007 17:17:41 +0100	[thread overview]
Message-ID: <474308A5.8070301@viscovery.net> (raw)
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:

> +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

  reply	other threads:[~2007-11-20 16:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-19 20:12 [PATCH] Fix start_command closing cmd->out/in regardless of cmd->close_out/in Ping Yin
2007-11-20 16:17 ` Johannes Sixt [this message]
2007-11-21  2:38   ` Ping Yin
2007-11-21  9:11     ` Junio C Hamano
2007-11-21 11:55       ` Ping Yin
  -- strict thread matches above, loose matches on Subject: below --
2007-11-18 17:36 Ping Yin
2007-11-18 18:52 ` Junio C Hamano
2007-11-19  7:39 ` Johannes Sixt
2007-11-19  8:46   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=474308A5.8070301@viscovery.net \
    --to=j.sixt@viscovery.net \
    --cc=git@vger.kernel.org \
    --cc=pkufranky@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.