Use is-terminal crate for now (#9670)

# Description
Until we bump our minimal Rust version to `1.70.0` we can't use
`std::io::IsTerminal`. The crate `is-terminal` (depending on `rustix` or
`windows-sys`) can provide the same.
Get's rid of the dependency on the outdated `atty` crate.
We already transitively depend on it (e.g. through `miette`)

As soon as we reach the new Rust version we can supersede this with
@nibon7's #9550

Co-authored-by: nibon7 <nibon7@163.com>
This commit is contained in:
Stefan Holderbach
2023-07-12 18:15:54 +02:00
committed by GitHub
parent 026335fff0
commit 39b43d1e4b
9 changed files with 22 additions and 50 deletions

View File

@@ -82,6 +82,7 @@ impl Drop for ForegroundChild {
// Note: we exclude macos because the techniques below seem to have issues in macos 13 currently.
#[cfg(all(target_family = "unix", not(target_os = "macos")))]
mod fg_process_setup {
use is_terminal::IsTerminal;
use nix::{
sys::signal,
unistd::{self, Pid},
@@ -138,7 +139,7 @@ mod fg_process_setup {
pub(super) fn set_foreground(process: &std::process::Child, existing_pgrp: u32) {
// called from the parent shell process - do the stdin tty check here
if atty::is(atty::Stream::Stdin) {
if std::io::stdin().is_terminal() {
set_foreground_pid(
Pid::from_raw(process.id() as i32),
existing_pgrp,
@@ -163,7 +164,7 @@ mod fg_process_setup {
/// Reset the foreground process group to the shell
pub(super) fn reset_foreground_id() {
if atty::is(atty::Stream::Stdin) {
if std::io::stdin().is_terminal() {
if let Err(e) = nix::unistd::tcsetpgrp(nix::libc::STDIN_FILENO, unistd::getpgrp()) {
println!("ERROR: reset foreground id failed, tcsetpgrp result: {e:?}");
}