Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/parallel/stderr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ pub fn set_non_blocking(stderr: &mut ChildStderr) -> Result<(), Error> {
{
use std::os::unix::io::AsRawFd;
let fd = stderr.as_raw_fd();
debug_assert_eq!(
unsafe { libc::fcntl(fd, libc::F_GETFL, 0) },
0,
"stderr should have no flags set"
);
let flags = unsafe { libc::fcntl(fd, libc::F_GETFL, 0) };
if flags == -1 {
return Err(Error::new(
ErrorKind::IOError,
format!(
"Failed to get flags for child stderr: {}",
std::io::Error::last_os_error()
),
));
}

if unsafe { libc::fcntl(fd, libc::F_SETFL, libc::O_NONBLOCK) } != 0 {
if unsafe { libc::fcntl(fd, libc::F_SETFL, flags | libc::O_NONBLOCK) } == -1 {
return Err(Error::new(
ErrorKind::IOError,
format!(
Expand Down