lists.zerezo.com
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fix start_command() pipe bug when stdin is closed.
- Date: Mon, 25 Aug 2008 12:44:08 +0200
- From: Johannes Sixt <j.sixt@xxxxxxxxxxxxx>
- Subject: Re: [PATCH] Fix start_command() pipe bug when stdin is closed.
Karl Chen schrieb:
> I ran into what I think is a bug:
> sh$ git fetch 0<&-
>
> (i.e. run git-fetch with stdin closed.)
> It aborts with:
> fatal: read error (Bad file descriptor)
When I try these instructions I don't get an error; instead the command
runs successfully.
> I think the problem arises from the use of dup2+close in
> start_command(). It wants to rename a pipe file descriptor to 0,
> so it does
> dup2(from, to);
> close(from);
>
> ... but in this case from == to == 0, so
> dup2(0, 0);
> close(0);
> just ends up closing the pipe.
While I do see that there is a problem, it is only half of the story, and
your patch addresses only this half.
What if stdout is closed, too? Then the ends of the first allocated pipe
would go to fds 0 and 1, and then the pipe end at 1 would be closed by a
subsequent dup2(xxx, 1).
Junio, what's your take on this?
-- 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