PEP-22: runner waits for tmux to reap the agent before reading its exit status
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
961cb558a4
commit
6cbac2bf4c
@ -45,9 +45,15 @@ export interface PaneState {
|
||||
}
|
||||
|
||||
export async function paneState(name: string): Promise<PaneState> {
|
||||
const out = (await tmux("display-message", "-p", "-t", `=${name}:`, "#{pane_dead} #{pane_dead_status}")).trim();
|
||||
const [dead, status] = out.split(" ");
|
||||
return { dead: dead === "1", exitStatus: status ? Number(status) : null };
|
||||
// tmux marks the pane dead when the pty closes, which can come before it reaps the child:
|
||||
// for a moment there is neither an exit status nor a signal. Give it a second to catch up.
|
||||
for (let attempt = 0; ; attempt++) {
|
||||
const out = (await tmux("display-message", "-p", "-t", `=${name}:`, "#{pane_dead} #{pane_dead_status} #{pane_dead_signal}")).trim();
|
||||
const [dead, status, signal] = out.split(" ");
|
||||
if (dead !== "1") return { dead: false, exitStatus: null };
|
||||
if (status || signal || attempt >= 10) return { dead: true, exitStatus: status ? Number(status) : null };
|
||||
await new Promise((r) => setTimeout(r, 100));
|
||||
}
|
||||
}
|
||||
|
||||
/** Visible screen (plus `history` lines of scrollback) as plain text. */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user