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

Re: [PATCH 2/2] test-terminal: drop stdin handling

From
Rubén Justo <rjusto@gmail.com>
Date
Jun 6, 2024, 16:14 UTC
Message-ID
<b1ac45ae-05d6-40ad-a9a1-3a83b5f662de@gmail.com>
In-Reply-To
<20240606082237.GB1167215@coredump.intra.peff.net>
On 6/6/24 10:22 AM, Jeff King wrote:
Show 32 quoted lines
> Since 18d8c26930 (test_terminal: redirect child process' stdin to a pty,
> 2015-08-04), we set up a pty and copy stdin to the child program. But
> this ends up being racy; once we send all of the bytes and close the
> descriptor, the child program will no longer see a terminal! isatty()
> will return 0, and trying to read may return EIO, even if we didn't yet
> get all of the bytes.
> 
> This was mentioned even in the commit message of 18d8c26930, but we
> hacked around it by just sending an infinite input from /dev/zero (in
> the intended case, we only cared about isatty(0), not reading actual
> input).
> 
> And it came up again recently in:
> 
>   https://lore.kernel.org/git/d42a55b1-1ba9-4cfb-9c3d-98ea4d86da33@gmail.com/
> 
> where we tried to actually send bytes, but they don't always all come
> through. So this interface is somewhat of an accident waiting to happen;
> a caller might not even care about stdin being a tty, but will get bit
> by the flaky behavior.
> 
> One solution would probably be to avoid closing test_terminal's end of
> the pty altogether. But then the other side would never see EOF on its
> stdin.  That may be OK for some cases, but it's another gotcha that
> might cause races or deadlocks, depending on what the child expects to
> read.
> 
> Let's instead just drop test_terminal's stdin feature completely. Since
> the previous commit dropped the two cases from t4153 for which the
> feature was originally added, there are no callers left that need it.
> 
> Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Rubén Justo <rjusto@gmail.com>
Previous: Jeff KingNext: Rubén Justo
Message 8 of 9 in “dropping stdin support from test-terminal”
  1. 0/2 dropping stdin support from test-terminalJeff King, Jun 6, 2024
  2. 1/2 am: add explicit "--retry" optionJeff King, Jun 6, 2024
  3. Junio C HamanoJun 6, 2024
  4. Junio C HamanoJun 6, 2024
  5. Jeff KingJun 8, 2024
  6. Phillip WoodJun 10, 2024
  7. 2/2 test-terminal: drop stdin handlingJeff King, Jun 6, 2024
  8. Rubén JustoJun 6, 2024
  9. Rubén JustoJun 6, 2024

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.