From: Ian Jackson Date: Wed, 23 Dec 2020 01:43:03 +0000 (+0000) Subject: closes fix it X-Git-Tag: otter-0.2.0~155 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=df3d863635bfba8cbc10c1f5c4c56a7dcf6168ab;p=otter.git closes fix it Signed-off-by: Ian Jackson --- diff --git a/wdriver.rs b/wdriver.rs index 5a792aa2..a0929bed 100644 --- a/wdriver.rs +++ b/wdriver.rs @@ -37,8 +37,10 @@ mod cleanup_notify { use anyhow::Context; use fehler::{throw, throws}; use libc::_exit; + use nix::errno::Errno::*; use nix::{unistd::*, fcntl::OFlag}; use nix::sys::signal::*; + use nix::Error::Sys; use void::Void; use std::io; use std::os::unix::io::RawFd; @@ -60,7 +62,7 @@ mod cleanup_notify { match nix::unistd::read(fd, &mut buf) { Ok(0) => break, Ok(_) => throw!(io::Error::from_raw_os_error(libc::EINVAL)), - Err(nix::Error::Sys(nix::errno::Errno::EINTR)) => continue, + Err(Sys(EINTR)) => continue, _ => throw!(io::Error::last_os_error()), } } @@ -100,6 +102,13 @@ mod cleanup_notify { ); let _ = close(writing_end); + for fd in 2.. { + if fd == notify_writing_end { continue } + let r = close(fd); + if fd >= writing_end && matches!(r, Err(Sys(EBADF))) { + break; + } + } let _ = read_await(notify_writing_end); let _ = kill(semidaemon, SIGTERM); _exit(0);