jesseduffield.lazygit/pkg/commands/oscommands
Stefan Haller d251faddec Reap pty process trees synchronously when quitting on Windows (#5879)
The pty teardown in Close runs on a background goroutine that doesn't
get to finish when lazygit is quitting: the process exits milliseconds
after the view buffer managers are closed. The job objects still cover
the clients -- KILL_ON_JOB_CLOSE reaps them when the process's handles
are rundown at exit -- but nothing reaps the conhost, so on Windows
builds whose conhost fails to run down on its own, quitting leaks one
conhost per live pty.

This is not a rare timing window: a diff longer than what has been
read keeps its git process (and thus its pty and conhost) running for
the entire time it is displayed, so that scrolling can read more.
Quitting while looking at a long diff is therefore the common case,
and with an external differ configured it leaks a conhost on affected
builds on almost every quit.

Fix this by having the gui's shutdown path wait synchronously for the
in-flight teardowns after closing the view buffer managers. A quit
signal makes the teardowns skip the conhost rundown wait -- the
conhost serves nothing once its clients are dead, and the exit must
not stall for its sake -- so the wait normally completes in
milliseconds, keeping quit as fast as before; a 2-second cap protects
the exit path even if a teardown wedges.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-04 07:03:27 +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 Reap pty process trees synchronously when quitting on Windows (#5879) 2026-08-04 07:03:27 +02:00
pty_windows.go Reap pty process trees synchronously when quitting on Windows (#5879) 2026-08-04 07:03:27 +02:00
pty_windows_test.go Reap pty process trees synchronously when quitting on Windows (#5879) 2026-08-04 07:03:27 +02:00