You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.1 KiB
65 lines
2.1 KiB
From 6f9feb2f34ce539cd67850d708768352485946c6 Mon Sep 17 00:00:00 2001
|
|
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
|
|
Date: Thu, 4 Jan 2018 23:52:45 +0100
|
|
Subject: [PATCH] deps: update nix to 0.9
|
|
|
|
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
|
|
---
|
|
src/lib.rs | 16 ++++++++++++----
|
|
1 file changed, 12 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/lib.rs b/src/lib.rs
|
|
index db6b72e..91e8afb 100644
|
|
--- a/src/lib.rs
|
|
+++ b/src/lib.rs
|
|
@@ -95,13 +95,21 @@ mod platform {
|
|
|
|
static mut PIPE: (RawFd, RawFd) = (-1, -1);
|
|
|
|
- extern fn os_handler(_: nix::c_int) {
|
|
+ extern fn os_handler(_: nix::libc::c_int) {
|
|
// Assuming this always succeeds. Can't really handle errors in any meaningful way.
|
|
unsafe {
|
|
unistd::write(PIPE.1, &[0u8]).is_ok();
|
|
}
|
|
}
|
|
|
|
+ fn nix_err_to_io_err(err: nix::Error) -> io::Error {
|
|
+ if let nix::Error::Sys(err_no) = err {
|
|
+ io::Error::from(err_no)
|
|
+ } else {
|
|
+ panic!("unexpected nix error type: {:?}", err)
|
|
+ }
|
|
+ }
|
|
+
|
|
/// Register os signal handler.
|
|
///
|
|
/// Must be called before calling [`block_ctrl_c()`](fn.block_ctrl_c.html)
|
|
@@ -115,12 +123,12 @@ mod platform {
|
|
use self::nix::fcntl;
|
|
use self::nix::sys::signal;
|
|
|
|
- PIPE = unistd::pipe2(fcntl::O_CLOEXEC).map_err(|e| Error::System(e.into()))?;
|
|
+ PIPE = unistd::pipe2(fcntl::O_CLOEXEC).map_err(|e| Error::System(nix_err_to_io_err(e)))?;
|
|
|
|
let close_pipe = |e: nix::Error| -> Error {
|
|
unistd::close(PIPE.1).is_ok();
|
|
unistd::close(PIPE.0).is_ok();
|
|
- Error::System(e.into())
|
|
+ Error::System(nix_err_to_io_err(e))
|
|
};
|
|
|
|
// Make sure we never block on write in the os handler.
|
|
@@ -172,7 +180,7 @@ mod platform {
|
|
Ok(1) => break,
|
|
Ok(_) => return Err(Error::System(io::ErrorKind::UnexpectedEof.into()).into()),
|
|
Err(nix::Error::Sys(nix::Errno::EINTR)) => {},
|
|
- Err(e) => return Err(Error::System(e.into())),
|
|
+ Err(e) => return Err(Error::System(nix_err_to_io_err(e))),
|
|
}
|
|
}
|
|
|
|
--
|
|
2.15.1
|
|
|