Repository navigation
Restore foreground process group when the debuggee exits - #2096
Rich Chiodo (rchiodo) merged 3 commits into
Conversation
|
Rich Chiodo (@rchiodo) the fix is up, ready for your review when you have a moment. Pavel Minaev (@int19h) tagging you as well since you have worked on the launcher. |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
I think this can take the terminal away from a still-running subprocess. I reproduced this with the PR's launcher on WSL: the debuggee starts a child that inherits stdin/stdout and exits; with Could we move the restore until after That doesn't settle the case where output isn't captured, or a child closes the captured streams but keeps using the terminal. Those cases may need an explicit decision about when to return terminal ownership to the shell versus keeping it with a surviving child. |
|
Yes Rich Chiodo (@rchiodo), process.wait() only covers the debuggee, the child processes are still in the same group. I will move the restore to after output.wait_for_remaining_output() and add a regression test with a surviving child. |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Rich Chiodo (@rchiodo) This is also ready to be merged. The only red check is the Windows py312 job, which was cancelled on Azure's 40 minute timeout at 98% with no test failure, and all other jobs passed. |
Fixes #2095.
When the launcher spawns the debuggee, the preexec in
launcher/debuggee.pyputs the debuggee in a new process group and makes that group the foreground group of the terminal withtcsetpgrp. Nothing ever set it back, so when the debuggee exited, the terminal was left with a dead foreground group. Shells with job control (bash) reclaim the foreground themselves, but pwsh has no Unix job control, so its next prompt read fails with an Input/output error and the debug terminal dies at the end of the run.This change restores the foreground group to the launcher's own group in
wait_for_exit, right after the debuggee exits:_restore_foreground_process_group()only acts when the current foreground group is still the debuggee's group, so it never takes the terminal away from anything else.wait_for_exitthread, wheresignal.signal()cannot be used, so SIGTTOU is blocked in that thread withpthread_sigmaskwhile callingtcsetpgrp.Tests: new pty regression test in
tests/tests/test_launcher_debuggee.pydrives the realdebuggee.spawn()and checks that the foreground group is the launcher's group again after the debuggee exits. It fails without the fix and passes with it. The fulltests/testssuite passes (67 tests), and thetest_runlaunch tests for integratedTerminal and internalConsole pass.