Subject: Re: [PATCH] git-daemon wrapper to wait until daemon is ready

From: Johannes Sixt <[email-masked]>
Date: Sun, 15 Apr 2012 19:11:52 +0200

Am 15.04.2012 00:06, schrieb Clemens Buchacher:
> On Sat, Apr 14, 2012 at 09:36:38PM +0200, Johannes Sixt wrote:
>> Am 14.04.2012 20:29, schrieb Clemens Buchacher:
>>> +	memset(&cat, 0, sizeof(cat));
>>> +	cat.argv = (const char **)cat_argv;
>>> +	cat.in = proc.err;
>>> +	cat.out = 2;
>>
>> Useless use of cat?
> 
> I don't see how I could avoid cat here. I have to create a pipe first so
> that I can read the first line. And then I have to terminate
> test-git-daemon in order to start the tests. So I cannot continue
> reading synchronously.

OK, I got it.

But reading the first line in this way needs a few assumptions to be true:

- git-daemon does not write an incomplete line and then waits.

- git-daemon does not write more than one line, because xread() happily
reads everything it can get. Your implementation differs from the old
version because the shell's 'read' is required to read no more than one
line, i.e., to read byte-wise from the pipe until it sees the LF.

-- Hannes