Re: [msysGit] [PATCH/RFC 07/11] run-command: support input-fd
From: Erik Faye-Lund <hidden>
Date: 2016-06-15 22:47:47
On Thu, Nov 26, 2009 at 10:53 PM, Johannes Sixt [off-list ref] wrote:
On Donnerstag, 26. November 2009, Erik Faye-Lund wrote:quoted
@@ -327,7 +327,10 @@ int start_async(struct async *async){ int pipe_out[2]; - if (pipe(pipe_out) < 0) + if (async->out) { + pipe_out[0] = dup(async->out); + pipe_out[1] = dup(async->out); + } else if (pipe(pipe_out) < 0) return error("cannot create pipe: %s", strerror(errno)); async->out = pipe_out[0];Hm. If async->out != 0: pipe_out[0] = dup(async->out); async->out = pipe_out[0]; This is confusing.
What do you find confusing about it? The idea is to use a provided bi-directional fd instead of a pipe if async->out is non-zero. The currently defined rules for async is that async->out must be zero (since the structure should be zero-initialized).
Moreover, you are assigning (a dup of) the same fd to the writable end. This assumes a bi-directional channel. I don't yet know what I should think about this (haven't studied the later patches, yet).
Indeed it does. Do we want to extend it to support a set of unidirectional channels instead?
It would be great if you could add a few words to Documentation/technical/api-runcommand.txt.
Ah, yes. I know I should update the documentation and all, I'm just usually really bad (*cough* lazy *cough*) at documenting stuff. But I'll give it a go and if people hate what I write, they can suggest changes. -- Erik "kusma" Faye-Lund