Skip to content

Commit

Permalink
Relax target cfg from linux to unix
Browse files Browse the repository at this point in the history
  • Loading branch information
mstallmo committed Aug 18, 2021
1 parent b619735 commit 3fa865b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lighthouse/environment/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ parking_lot = "0.11.0"
slog-json = "2.3.0"
exit-future = "0.2.0"

[target.'cfg(not(target_os = "linux"))'.dependencies]
[target.'cfg(not(target_family = "unix"))'.dependencies]
ctrlc = { version = "3.1.6", features = ["termination"] }
14 changes: 7 additions & 7 deletions lighthouse/environment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ use task_executor::{ShutdownReason, TaskExecutor};
use tokio::runtime::{Builder as RuntimeBuilder, Runtime};
use types::{EthSpec, MainnetEthSpec, MinimalEthSpec};

#[cfg(target_os = "linux")]
#[cfg(target_family = "unix")]
use {
futures::Future,
std::{pin::Pin, task::Context, task::Poll},
tokio::signal::unix::{signal, Signal, SignalKind},
};

#[cfg(not(target_os = "linux"))]
#[cfg(not(target_family = "unix"))]
use {futures::channel::oneshot, std::cell::RefCell};

const LOG_CHANNEL_SIZE: usize = 2048;
Expand Down Expand Up @@ -346,7 +346,7 @@ impl<E: EthSpec> Environment<E> {
/// Block the current thread until a shutdown signal is received.
///
/// This can be either the user Ctrl-C'ing or a task requesting to shutdown.
#[cfg(target_os = "linux")]
#[cfg(target_family = "unix")]
pub fn block_until_shutdown_requested(&mut self) -> Result<ShutdownReason, String> {
// future of a task requesting to shutdown
let mut rx = self
Expand Down Expand Up @@ -412,7 +412,7 @@ impl<E: EthSpec> Environment<E> {
/// Block the current thread until a shutdown signal is received.
///
/// This can be either the user Ctrl-C'ing or a task requesting to shutdown.
#[cfg(not(target_os = "linux"))]
#[cfg(not(target_family = "unix"))]
pub fn block_until_shutdown_requested(&mut self) -> Result<ShutdownReason, String> {
// future of a task requesting to shutdown
let mut rx = self
Expand Down Expand Up @@ -493,20 +493,20 @@ pub fn null_logger() -> Result<Logger, String> {
.map_err(|e| format!("Failed to start null logger: {:?}", e))
}

#[cfg(target_os = "linux")]
#[cfg(target_family = "unix")]
struct SignalFuture {
signal: Signal,
message: &'static str,
}

#[cfg(target_os = "linux")]
#[cfg(target_family = "unix")]
impl SignalFuture {
pub fn new(signal: Signal, message: &'static str) -> SignalFuture {
SignalFuture { signal, message }
}
}

#[cfg(target_os = "linux")]
#[cfg(target_family = "unix")]
impl Future for SignalFuture {
type Output = Option<ShutdownReason>;

Expand Down

0 comments on commit 3fa865b

Please sign in to comment.