git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] run-command: Remove set_nonblocking

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 5, 2015, 20:50 UTC
Message-ID
<xmqqa8qs5fxi.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<563BBBBC.7070807@kdbg.org>
Johannes Sixt <j6t@kdbg.org> writes:
Show 18 quoted lines
> Am 05.11.2015 um 19:17 schrieb Stefan Beller:
>> strbuf_read_once can also operate on blocking file descriptors if we are
>> sure they are ready. The poll (2) command however makes sure this is the
>> case.
>> 
>> Reading the manual for poll (2), there may be spurious returns indicating
>> readiness but that is for network sockets only. Pipes should be unaffected.
>> By having this patch, we rely on the correctness of poll to return
>> only pipes ready to read.
>> 
>> This fixes compilation in Windows.
>
> It certainly does (but I haven't tested, yet). But parallel processes
> will not work because we do not have a sufficiently complete waitpid
> emulation, yet. (waitpid(-1, ...) is not implemented.)
>
> However, I think that the infrastructure can be simplified even further
> to a level that we do not need additional emulation on Windows.
;-)

This is why I love this list (and in general not rushing any change too early to 'next').

Show 19 quoted lines
> Which makes me think: Other users of start_command/finish_command work
> such that they
>
> 1. request a pipe by setting .out = -1
> 2. start_command
> 3. read from .out until EOF
> 4. close .out
> 5. wait for the process with finish_command
>
> But the parallel_process infrastructure does not follow this pattern.
> It
>
> 1. requests a pipe by setting .err = -1
> 2. start_command
> 3. read from .err
> 4. wait for the process with waitpid
>
> (and forgets to close .err). EOF is not in the picture (but that is
> not essential).

Unrelated tangent. daemon is another one that uses start_command() but does not use finish_command().

> I suggest to change this such that we read from the children until EOF,
> mark them to be at their end of life, and then wait for them using
> finish_command (assuming that a process that closes stdout and stderr
> will die very soon if it is not already dead).

Hmm, interesting. This does match the normal "spawn, interact and wait" cycle for a single process much better.

Previous: Johannes SixtNext: Stefan Beller
Message 7 of 12 in “Remove non-blocking fds from run-command.”
  1. 0/2 Remove non-blocking fds from run-command.Stefan Beller, Nov 5, 2015
  2. 1/2 run-command: Remove set_nonblockingStefan Beller, Nov 5, 2015
  3. Junio C HamanoNov 5, 2015
  4. Stefan BellerNov 5, 2015
  5. Junio C HamanoNov 5, 2015
  6. Johannes SixtNov 5, 2015
  7. Junio C HamanoNov 5, 2015
  8. Stefan BellerNov 5, 2015
  9. Johannes SixtNov 6, 2015
  10. Stefan BellerNov 6, 2015
  11. Johannes SixtNov 6, 2015
  12. 2/2 strbuf: Correct documentation for strbuf_read_onceStefan Beller, Nov 5, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.