Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(windows): keep stdin open for conpty processes #8885

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions crates/turborepo-lib/src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ impl ProcessManager {
let use_pty = !cfg!(windows) && atty::is(atty::Stream::Stdout);
Self::new(use_pty)
}

/// Returns whether children will be spawned attached to a pseudoterminal
pub fn use_pty(&self) -> bool {
self.use_pty
}

/// Returns whether or not closing a child's stdin will result in it
/// immediately exiting.
pub fn closing_stdin_ends_process(&self) -> bool {
// Processes spawned hooked up to ConPTY on Windows will immediately exit
// if their stdin is closed. We avoid closing stdin in this case.
cfg!(windows) && self.use_pty
}
}

impl ProcessManager {
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/task_graph/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ impl ExecContext {
// Even if user does not have the TUI and cannot interact with a task, we keep
// stdin open for persistent tasks as some programs will shut down if stdin is
// closed.
if !self.takes_input {
if !self.takes_input && !self.manager.closing_stdin_ends_process() {
process.stdin();
}

Expand Down
Loading