fixed terminal

This commit is contained in:
Penwing 2024-01-25 20:44:31 +01:00
parent 09029d24b7
commit fd1e818447

View file

@ -4,6 +4,10 @@ use std::io::BufReader;
use std::io::Read;
use std::process::Stdio;
use std::{env, path::Path, process::Command};
use std::os::fd::AsRawFd;
use nix::fcntl::OFlag;
use nix::fcntl::FcntlArg;
use nix::fcntl::fcntl;
pub struct CommandEntry {
pub env: String,
@ -98,5 +102,11 @@ pub fn execute(
let stdout = child.stdout.take().unwrap();
let stderr = child.stderr.take().unwrap();
let stdout_fd = stdout.as_raw_fd();
let stderr_fd = stderr.as_raw_fd();
fcntl(stdout_fd, FcntlArg::F_SETFL(OFlag::O_NONBLOCK)).expect("Failed to set non-blocking mode");
fcntl(stderr_fd, FcntlArg::F_SETFL(OFlag::O_NONBLOCK)).expect("Failed to set non-blocking mode");
return (BufReader::new(stdout), BufReader::new(stderr));
}