From c6da876c3ef4ec9437c269b35bb3b569d159852d Mon Sep 17 00:00:00 2001 From: MaxVerevkin Date: Sat, 30 Mar 2024 19:34:08 +0200 Subject: use libc directly --- src/status_cmd.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/status_cmd.rs') diff --git a/src/status_cmd.rs b/src/status_cmd.rs index 0d6f049..243b209 100644 --- a/src/status_cmd.rs +++ b/src/status_cmd.rs @@ -1,4 +1,4 @@ -use std::io::{BufWriter, ErrorKind, Write}; +use std::io::{self, BufWriter, ErrorKind, Write}; use std::os::unix::io::AsRawFd; use std::process::{Child, ChildStdin, ChildStdout, Command, Stdio}; @@ -25,10 +25,9 @@ impl StatusCmd { .spawn()?; let output = child.stdout.take().unwrap(); let input = BufWriter::new(child.stdin.take().unwrap()); - nix::fcntl::fcntl( - output.as_raw_fd(), - nix::fcntl::F_SETFL(nix::fcntl::OFlag::O_NONBLOCK), - )?; + if unsafe { libc::fcntl(output.as_raw_fd(), libc::F_SETFL, libc::O_NONBLOCK) } == -1 { + return Err(io::Error::last_os_error().into()); + } Ok(Self { child, output, -- cgit v1.3.1