mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
Deduplicate nix
dependency versions (#12307)
# Description Now we only use `nix 0.28.0` Achieved by - updating `ctrlc` to `3.4.4` - updating `wl-clipboard-rs` to `0.8.1` - update our own dependency on `nix` from `0.27` to `0.28` - required fixing uses of `nix::unistd::{tcgetpgrp,tcsetpgrp}` - now requires an I/O safe file descriptor - fake one pointing to `libc::STDIN_FILENO` (we were only accessing `0` previously, dito for fish) # User-Facing Changes Better compile times and less to download as source dependencies
This commit is contained in:
committed by
GitHub
parent
bf8de9d1ea
commit
dfbbacfdf8
@ -12,6 +12,9 @@ use std::{
|
||||
},
|
||||
};
|
||||
|
||||
#[cfg(unix)]
|
||||
pub use foreground_pgroup::stdin_fd;
|
||||
|
||||
/// A simple wrapper for [`std::process::Child`]
|
||||
///
|
||||
/// It can only be created by [`ForegroundChild::spawn`].
|
||||
@ -98,15 +101,28 @@ impl Drop for ForegroundChild {
|
||||
#[cfg(unix)]
|
||||
mod foreground_pgroup {
|
||||
use nix::{
|
||||
libc,
|
||||
sys::signal::{sigaction, SaFlags, SigAction, SigHandler, SigSet, Signal},
|
||||
unistd::{self, Pid},
|
||||
};
|
||||
use std::{
|
||||
os::unix::prelude::CommandExt,
|
||||
os::{
|
||||
fd::{AsFd, BorrowedFd},
|
||||
unix::prelude::CommandExt,
|
||||
},
|
||||
process::{Child, Command},
|
||||
};
|
||||
|
||||
/// Alternative to having to call `std::io::stdin()` just to get the file descriptor of stdin
|
||||
///
|
||||
/// # Safety
|
||||
/// I/O safety of reading from `STDIN_FILENO` unclear.
|
||||
///
|
||||
/// Currently only intended to access `tcsetpgrp` and `tcgetpgrp` with the I/O safe `nix`
|
||||
/// interface.
|
||||
pub unsafe fn stdin_fd() -> impl AsFd {
|
||||
unsafe { BorrowedFd::borrow_raw(libc::STDIN_FILENO) }
|
||||
}
|
||||
|
||||
pub fn prepare_command(external_command: &mut Command, existing_pgrp: u32) {
|
||||
unsafe {
|
||||
// Safety:
|
||||
@ -154,12 +170,12 @@ mod foreground_pgroup {
|
||||
Pid::from_raw(existing_pgrp as i32)
|
||||
};
|
||||
let _ = unistd::setpgid(pid, pgrp);
|
||||
let _ = unistd::tcsetpgrp(libc::STDIN_FILENO, pgrp);
|
||||
let _ = unistd::tcsetpgrp(unsafe { stdin_fd() }, pgrp);
|
||||
}
|
||||
|
||||
/// Reset the foreground process group to the shell
|
||||
pub fn reset() {
|
||||
if let Err(e) = unistd::tcsetpgrp(libc::STDIN_FILENO, unistd::getpgrp()) {
|
||||
if let Err(e) = unistd::tcsetpgrp(unsafe { stdin_fd() }, unistd::getpgrp()) {
|
||||
eprintln!("ERROR: reset foreground id failed, tcsetpgrp result: {e:?}");
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ pub mod os_info;
|
||||
#[cfg(target_os = "windows")]
|
||||
mod windows;
|
||||
|
||||
#[cfg(unix)]
|
||||
pub use self::foreground::stdin_fd;
|
||||
pub use self::foreground::ForegroundChild;
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub use self::linux::*;
|
||||
|
Reference in New Issue
Block a user