Re: [msysGit] [PATCH/RFC 07/11] run-command: support input-fd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Donnerstag, 26. November 2009, Erik Faye-Lund wrote:
> This patch adds the possibility to supply a non-0
> file descriptor for communucation, instead of the
> default-created pipe. The pipe gets duplicated, so
> the caller can free it's handles.
>
> This is usefull for async communication over sockets.
>
> Signed-off-by: Erik Faye-Lund <kusmabite@xxxxxxxxx>
> ---
>  run-command.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/run-command.c b/run-command.c
> index e5a0e06..98771ef 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -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.

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).

It would be great if you could add a few words to 
Documentation/technical/api-runcommand.txt.

-- Hannes
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]