Skip to content

Commit fb51e45

Browse files
authored
linera windows (#3401)
Helps with compiling linera on windows.
1 parent e30dd6d commit fb51e45

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

linera-base/src/lib.rs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ use std::fmt;
1212

1313
#[doc(hidden)]
1414
pub use async_trait::async_trait;
15+
#[cfg(all(not(target_arch = "wasm32"), unix))]
16+
use tokio::signal::unix;
1517
#[cfg(not(target_arch = "wasm32"))]
16-
use {::tracing::debug, tokio::signal::unix, tokio_util::sync::CancellationToken};
18+
use {::tracing::debug, tokio_util::sync::CancellationToken};
1719
pub mod abi;
1820
#[cfg(not(target_arch = "wasm32"))]
1921
pub mod command;
@@ -158,16 +160,27 @@ pub fn hex_vec_debug(list: &Vec<Vec<u8>>, f: &mut fmt::Formatter) -> fmt::Result
158160
pub async fn listen_for_shutdown_signals(shutdown_sender: CancellationToken) {
159161
let _shutdown_guard = shutdown_sender.drop_guard();
160162

161-
let mut sigint =
162-
unix::signal(unix::SignalKind::interrupt()).expect("Failed to set up SIGINT handler");
163-
let mut sigterm =
164-
unix::signal(unix::SignalKind::terminate()).expect("Failed to set up SIGTERM handler");
165-
let mut sighup =
166-
unix::signal(unix::SignalKind::hangup()).expect("Failed to set up SIGHUP handler");
163+
#[cfg(unix)]
164+
{
165+
let mut sigint =
166+
unix::signal(unix::SignalKind::interrupt()).expect("Failed to set up SIGINT handler");
167+
let mut sigterm =
168+
unix::signal(unix::SignalKind::terminate()).expect("Failed to set up SIGTERM handler");
169+
let mut sighup =
170+
unix::signal(unix::SignalKind::hangup()).expect("Failed to set up SIGHUP handler");
167171

168-
tokio::select! {
169-
_ = sigint.recv() => debug!("Received SIGINT"),
170-
_ = sigterm.recv() => debug!("Received SIGTERM"),
171-
_ = sighup.recv() => debug!("Received SIGHUP"),
172+
tokio::select! {
173+
_ = sigint.recv() => debug!("Received SIGINT"),
174+
_ = sigterm.recv() => debug!("Received SIGTERM"),
175+
_ = sighup.recv() => debug!("Received SIGHUP"),
176+
}
177+
}
178+
179+
#[cfg(windows)]
180+
{
181+
tokio::signal::ctrl_c()
182+
.await
183+
.expect("Failed to set up Ctrl+C handler");
184+
debug!("Received Ctrl+C");
172185
}
173186
}

0 commit comments

Comments
 (0)