Request a PTY for remote exec so build output streams live

Without a PTY, ninja/gclient/python block-buffer their output when stdout
isn't a terminal, which can make a multi-hour build look stalled in the CI
log for long stretches even though it's progressing fine.
This commit is contained in:
Philip Peterson 2026-08-04 00:22:56 -08:00
parent 4841b74cc1
commit d40351daa3

19
main.go
View file

@ -415,6 +415,25 @@ func sshSession(st *state) (*ssh.Session, *ssh.Client, error) {
client.Close()
return nil, nil, err
}
// A PTY makes the remote side (ninja, gclient, python) think it's
// talking to a terminal, so it line-buffers instead of block-buffering
// for a non-tty pipe -- without this, output for a multi-hour build can
// arrive in laggy multi-KB chunks instead of streaming as it happens.
// Combines stderr into stdout, which is fine for a CI log (one
// interleaved stream is what you'd see watching a real terminal
// anyway).
modes := ssh.TerminalModes{
ssh.ECHO: 0,
ssh.TTY_OP_ISPEED: 14400,
ssh.TTY_OP_OSPEED: 14400,
}
if err := session.RequestPty("xterm", 40, 200, modes); err != nil {
session.Close()
client.Close()
return nil, nil, fmt.Errorf("requesting pty: %w", err)
}
return session, client, nil
}