forked from extern/nushell
Revert "Fix SIGTTIN handling" (#9694)
Reverts nushell/nushell#9681 As mentioned in #9681 - this breaks running tests in wsl2.
This commit is contained in:
parent
3ffafa7196
commit
b693db16cc
@ -59,11 +59,12 @@ fn take_control(interactive: bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut success = false;
|
||||||
for _ in 0..4096 {
|
for _ in 0..4096 {
|
||||||
match unistd::tcgetpgrp(nix::libc::STDIN_FILENO) {
|
match unistd::tcgetpgrp(nix::libc::STDIN_FILENO) {
|
||||||
Ok(owner_pgid) if owner_pgid == shell_pgid => {
|
Ok(owner_pgid) if owner_pgid == shell_pgid => {
|
||||||
// success
|
success = true;
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
Ok(owner_pgid) if owner_pgid == Pid::from_raw(0) => {
|
Ok(owner_pgid) if owner_pgid == Pid::from_raw(0) => {
|
||||||
// Zero basically means something like "not owned" and we can just take it
|
// Zero basically means something like "not owned" and we can just take it
|
||||||
@ -79,7 +80,7 @@ fn take_control(interactive: bool) {
|
|||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// fish also has other heuristics than "too many attempts" for the orphan check, but they're optional
|
// fish also has other heuristics than "too many attempts" for the orphan check, but they're optional
|
||||||
if signal::killpg(shell_pgid, Signal::SIGTTIN).is_err() {
|
if signal::killpg(Pid::from_raw(-shell_pgid.as_raw()), Signal::SIGTTIN).is_err() {
|
||||||
if !interactive {
|
if !interactive {
|
||||||
// that's fine
|
// that's fine
|
||||||
return;
|
return;
|
||||||
@ -90,8 +91,7 @@ fn take_control(interactive: bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !success && interactive {
|
||||||
if interactive {
|
|
||||||
eprintln!("ERROR: failed take control of the terminal, we might be orphaned");
|
eprintln!("ERROR: failed take control of the terminal, we might be orphaned");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user