mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 17:31:14 -03:00
Retry some writes on EINTR again
I guess?
Fixes f0e007c439 (Relocate tty metadata and protocols and clean it up,
2025-06-19).
This commit is contained in:
@@ -1355,7 +1355,7 @@ pub fn valid_func_name(name: &wstr) -> bool {
|
||||
|
||||
/// A rusty port of the C++ `write_loop()` function from `common.cpp`. This should be deprecated in
|
||||
/// favor of native rust read/write methods at some point.
|
||||
pub fn write_loop<Fd: AsRawFd>(fd: &Fd, buf: &[u8]) -> std::io::Result<()> {
|
||||
pub fn safe_write_loop<Fd: AsRawFd>(fd: &Fd, buf: &[u8]) -> std::io::Result<()> {
|
||||
let fd = fd.as_raw_fd();
|
||||
let mut total = 0;
|
||||
while total < buf.len() {
|
||||
@@ -1374,6 +1374,8 @@ pub fn write_loop<Fd: AsRawFd>(fd: &Fd, buf: &[u8]) -> std::io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub use safe_write_loop as write_loop;
|
||||
|
||||
// Output writes always succeed; this adapter allows us to use it in a write-like macro.
|
||||
struct OutputWriteAdapter<'a, T: Output>(&'a mut T);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Utility for transferring the tty to a child process in a scoped way,
|
||||
//! and reclaiming it after.
|
||||
|
||||
use crate::common;
|
||||
use crate::common::{self, safe_write_loop};
|
||||
use crate::flog::{FLOG, FLOGF};
|
||||
use crate::global_safety::RelaxedAtomicBool;
|
||||
use crate::job_group::JobGroup;
|
||||
@@ -18,7 +18,6 @@
|
||||
use crate::wutil::perror;
|
||||
use libc::{EINVAL, ENOTTY, EPERM, STDIN_FILENO, WNOHANG};
|
||||
use std::mem::MaybeUninit;
|
||||
use std::os::fd::BorrowedFd;
|
||||
use std::sync::atomic::{AtomicBool, AtomicPtr, AtomicU8, Ordering};
|
||||
|
||||
// Facts about our environment, which inform how we handle the tty.
|
||||
@@ -316,8 +315,7 @@ pub fn safe_deactivate_tty_protocols() {
|
||||
|
||||
let commands = protocols.safe_get_commands(false);
|
||||
// Safety: just writing data to stdout.
|
||||
let stdout_fd = unsafe { BorrowedFd::borrow_raw(libc::STDOUT_FILENO) };
|
||||
let _ = nix::unistd::write(stdout_fd, commands);
|
||||
let _ = safe_write_loop(&libc::STDOUT_FILENO, commands);
|
||||
TTY_PROTOCOLS_ACTIVE.store(false, Ordering::Release);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user