jesseduffield.lazygit/pkg/commands/oscommands
Stefan Haller a61be44e92 Wait for the streamed command's output goroutine before reading its buffers
runAndStreamAux reads the stdout buffer (and, when output is suppressed,
the combinedOutput buffer) for its error message after handler.wait()
returns, but the goroutine that fills those buffers by draining the
command's output isn't awaited, so the reads raced its final writes.

Own the goroutine here rather than letting the onRun callbacks spawn it,
and join it before reading the buffers. The pty reader reaches EOF on its
own once the process exits, but the non-pty pipe never does, so its
handler now closes the read end to unblock the reader; the pipe is
synchronous, so by the time the command has exited all of its output has
already been read and nothing is lost. This also plugs the goroutine that
the non-pty streaming path previously leaked on every command.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 12:19:14 +02:00
..
cmd_obj.go Use ConPTY on Windows for pty-backed command execution 2026-07-03 18:47:15 +02:00
cmd_obj_builder.go Fix quoting of shell commands on Windows 2026-06-23 14:11:00 +02:00
cmd_obj_runner.go Wait for the streamed command's output goroutine before reading its buffers 2026-07-17 12:19:14 +02:00
cmd_obj_runner_test.go Copy gocui files into lazygit repo under pkg/gocui 2026-04-30 14:29:08 +02:00
cmd_obj_test.go Suppress optional locks by default again, except foreground refresh 2026-07-02 16:05:08 +02:00
copy.go Specify return value where named return value is used 2025-10-20 07:56:56 +02:00
dummies.go Remove empty directories after discarding files 2026-03-30 17:50:28 +02:00
fake_cmd_obj_runner.go Remove ICmdObj interface 2025-05-01 15:21:37 +02:00
gui_io.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
new_shell_windows_test.go Add end-to-end test for shell command quoting on Windows 2026-06-23 14:11:00 +02:00
os.go Remove empty directories after discarding files 2026-03-30 17:50:28 +02:00
os_default_platform.go Abstract task command over *exec.Cmd 2026-07-03 18:47:15 +02:00
os_default_test.go Clean up build tags 2025-08-14 20:40:44 +02:00
os_test.go Fix quoting of shell commands on Windows 2026-06-23 14:11:00 +02:00
os_windows.go Abstract task command over *exec.Cmd 2026-07-03 18:47:15 +02:00
os_windows_test.go Fix quoting of shell commands on Windows 2026-06-23 14:11:00 +02:00
pty.go Add pty support on Windows via ConPTY 2026-07-03 18:47:15 +02:00
pty_unix.go Abstract pty startup behind a platform-specific primitive 2026-07-03 18:47:15 +02:00
pty_windows.go Fix a deadlock when a Windows pty task is stopped mid-output 2026-07-15 10:31:11 +02:00