mirror of
https://github.com/nushell/nushell.git
synced 2025-02-18 03:21:05 +01:00
Fix panic when encountering ENOTTY. (#7001)
This commit is contained in:
parent
36ae384fb3
commit
f1bde69131
21
src/main.rs
21
src/main.rs
@ -45,17 +45,18 @@ fn take_control(interactive: bool) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let shell_pgid = unistd::getpgrp();
|
let shell_pgid = unistd::getpgrp();
|
||||||
let owner_pgid = unistd::tcgetpgrp(nix::libc::STDIN_FILENO).expect("tcgetpgrp");
|
|
||||||
|
|
||||||
// Common case, nothing to do
|
match unistd::tcgetpgrp(nix::libc::STDIN_FILENO) {
|
||||||
if owner_pgid == shell_pgid {
|
Ok(owner_pgid) if owner_pgid == shell_pgid => {
|
||||||
return;
|
// Common case, nothing to do
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
// This can apparently happen with sudo: https://github.com/fish-shell/fish-shell/issues/7388
|
Ok(owner_pgid) if owner_pgid == unistd::getpid() => {
|
||||||
if owner_pgid == unistd::getpid() {
|
// This can apparently happen with sudo: https://github.com/fish-shell/fish-shell/issues/7388
|
||||||
let _ = unistd::setpgid(owner_pgid, owner_pgid);
|
let _ = unistd::setpgid(owner_pgid, owner_pgid);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset all signal handlers to default
|
// Reset all signal handlers to default
|
||||||
|
Loading…
Reference in New Issue
Block a user