Skip to content

Do not make the child a session leader#1586

Merged
j178 merged 1 commit intomasterfrom
pty
Feb 6, 2026
Merged

Do not make the child a session leader#1586
j178 merged 1 commit intomasterfrom
pty

Conversation

@j178
Copy link
Owner

@j178 j178 commented Feb 6, 2026

Closes #1561
Previous fix: #1363

We run subcommands under a PTY so they behave like they do in an interactive terminal (colors, progress bars, etc.). However, this is still a pseudo-terminal and it doesn't necessarily provide a full/accurate terminal environment.

Some libraries (for example Go's termenv) send OSC/CSI queries and wait for a response from the terminal. Our PTY doesn't emulate those responses, so they can block on a timeout if the program insists on probing capabilities.

Previously, we tried to work around this by setting TERM=dumb in the environment, but that caused other issues (for example, some programs (e.g cargo), disable color entirely when they see TERM=dumb, even if the output is actually a terminal that supports color).

We intentionally do not make the child a session leader/foreground process group here. When we did, termenv detected it as foreground and ran OSC probes, which then hung.

We run some commands under a PTY so they behave like they do in an interactive terminal (colors, progress bars, etc.). However, this is still a *pseudo*-terminal and it doesn't necessarily provide a full/accurate terminal environment.

Some libraries (for example Go's termenv) send OSC/CSI queries and wait for a response from the terminal. Our PTY doesn't emulate those responses, so they can block on a timeout if the program insists on probing capabilities.

Previously, we tried to work around this by setting `TERM=dumb` in the environment, but that caused other issues (for example, some programs (e.g cargo), disable color entirely when they see `TERM=dumb`, even if the output is actually a terminal that supports color).

We intentionally do not make the child a session leader/foreground process group here. When we did, termenv detected it as foreground and ran OSC probes, which then hung.
Copilot AI review requested due to automatic review settings February 6, 2026 10:06
@j178 j178 added the bug Something isn't working label Feb 6, 2026
@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.65%. Comparing base (3fa9187) to head (a8db079).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1586      +/-   ##
==========================================
- Coverage   91.65%   91.65%   -0.01%     
==========================================
  Files          93       93              
  Lines       18280    18277       -3     
==========================================
- Hits        16755    16751       -4     
- Misses       1525     1526       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes hanging issues with PTY process execution by removing the session leader setup and TERM=dumb environment variable setting. Previously, these workarounds were intended to prevent terminal capability probing issues, but they caused other problems (tools like cargo would disable colors entirely). The new approach simply avoids making the child a session leader, which prevents libraries like Go's termenv from detecting the process as foreground and attempting OSC probes that would hang.

Changes:

  • Removed session leader setup for PTY child processes to prevent hanging on OSC/CSI capability probes
  • Removed TERM=dumb environment variable setting that caused color output to be disabled in some tools
  • Cleaned up unused TERM constant and import
  • Removed completed TODO comment in list command

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
crates/prek/src/process.rs Removed session leader setup and TERM=dumb workarounds; updated explanatory comments
crates/prek-consts/src/env_vars.rs Removed unused TERM constant
crates/prek/src/cli/list.rs Removed TODO comment that was already completed (full_id already includes project prefix)

@prek-ci-bot
Copy link

prek-ci-bot bot commented Feb 6, 2026

📦 Cargo Bloat Comparison

Binary size change: +0.00% (23.7 MiB → 23.7 MiB)

Expand for cargo-bloat output

Head Branch Results

 File  .text    Size             Crate Name
 0.3%   0.8% 82.3KiB             prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.3%   0.7% 71.1KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.6% 65.6KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 51.2KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.5% 50.5KiB              prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.4% 41.5KiB              prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4% 38.4KiB              prek prek::run::{{closure}}
 0.1%   0.3% 32.0KiB             prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.3% 28.4KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.3% 28.3KiB              prek prek::identify::by_extension::{{closure}}
 0.1%   0.2% 24.8KiB             prek? <prek::config::_::<impl serde_core::de::Deserialize for prek::config::Config>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
 0.1%   0.2% 22.6KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2% 22.1KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 22.1KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 21.2KiB      clap_builder clap_builder::parser::parser::Parser::get_matches_with
 0.1%   0.2% 20.0KiB   cargo_metadata? <cargo_metadata::_::<impl serde_core::de::Deserialize for cargo_metadata::Package>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
 0.1%   0.2% 19.5KiB              prek prek::archive::unzip::{{closure}}
 0.1%   0.2% 19.5KiB              prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 19.3KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{closure}}>
 0.1%   0.2% 19.2KiB              prek <prek::languages::ruby::ruby::Ruby as prek::languages::LanguageImpl>::install::{{closure}}
38.4%  91.5%  9.1MiB                   And 20917 smaller methods. Use -n N to show more.
41.9% 100.0%  9.9MiB                   .text section size, the file size is 23.7MiB

Base Branch Results

 File  .text    Size             Crate Name
 0.3%   0.8% 81.8KiB             prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.3%   0.7% 71.1KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.6% 65.6KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 51.2KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.5% 50.5KiB              prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.4% 41.4KiB              prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4% 38.4KiB              prek prek::run::{{closure}}
 0.1%   0.3% 31.3KiB             prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.3% 28.4KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.3% 28.3KiB              prek prek::identify::by_extension::{{closure}}
 0.1%   0.2% 24.8KiB             prek? <prek::config::_::<impl serde_core::de::Deserialize for prek::config::Config>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
 0.1%   0.2% 22.6KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2% 22.1KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 22.1KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 21.2KiB      clap_builder clap_builder::parser::parser::Parser::get_matches_with
 0.1%   0.2% 20.0KiB   cargo_metadata? <cargo_metadata::_::<impl serde_core::de::Deserialize for cargo_metadata::Package>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
 0.1%   0.2% 19.5KiB              prek prek::archive::unzip::{{closure}}
 0.1%   0.2% 19.5KiB              prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 19.3KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{closure}}>
 0.1%   0.2% 19.2KiB              prek <prek::languages::ruby::ruby::Ruby as prek::languages::LanguageImpl>::install::{{closure}}
38.4%  91.6%  9.1MiB                   And 20905 smaller methods. Use -n N to show more.
41.9% 100.0%  9.9MiB                   .text section size, the file size is 23.7MiB

@j178 j178 merged commit 72a78ee into master Feb 6, 2026
55 checks passed
@j178 j178 deleted the pty branch February 6, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No color in hook output

2 participants