From: Junio C Hamano <gitster@pobox.com>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: Ping Yin <pkufranky@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] Fix start_command closing cmd->out/in regardless of cmd->close_out/in
Date: Mon, 19 Nov 2007 00:46:17 -0800 [thread overview]
Message-ID: <7vfxz2oc6e.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <47413DB9.9030306@viscovery.net> (Johannes Sixt's message of "Mon, 19 Nov 2007 08:39:37 +0100")
Johannes Sixt <j.sixt@viscovery.net> writes:
> Ping Yin schrieb:
>> When 'FILE *fp' is assigned to child_process.out and then start_command or
>> run_command is run, the standard output of the child process is expected to
>> be outputed to fp. However, sometimes fp is not expected to be closed since
>> further IO may be still performmed on fp.
>> ---
>> run-command.c | 4 ----
>> 1 files changed, 0 insertions(+), 4 deletions(-)
>>
>> diff --git a/run-command.c b/run-command.c
>> index 476d00c..4e5f58d 100644
>> --- a/run-command.c
>> +++ b/run-command.c
>> @@ -115,13 +115,9 @@ int start_command(struct child_process *cmd)
>> if (need_in)
>> close(fdin[0]);
>> - else if (cmd->in)
>> - close(cmd->in);
>> if (need_out)
>> close(fdout[1]);
>> - else if (cmd->out > 1)
>> - close(cmd->out);
>> if (need_err)
>> close(fderr[1]);
>
> This is dangerous! You have to audit all current callers whether they
> close cmd->in or cmd->out (if they don't need the fd
> anymore).
I am reasonably sure that they are already relying on these auto
closing of the file descriptors.
Funny that somebody falls into the trap the day after we
discussed it on another thread.
next prev parent reply other threads:[~2007-11-19 8:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-18 17:36 [PATCH] Fix start_command closing cmd->out/in regardless of cmd->close_out/in 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 [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-11-19 20:12 Ping Yin
2007-11-20 16:17 ` Johannes Sixt
2007-11-21 2:38 ` Ping Yin
2007-11-21 9:11 ` Junio C Hamano
2007-11-21 11:55 ` Ping Yin
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=7vfxz2oc6e.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=j.sixt@viscovery.net \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).