Skip to content

Commit 8e2e931

Browse files
committed
replace signal-hook with ctrlc in hopes of better Windows support
1 parent c15eb72 commit 8e2e931

File tree

3 files changed

+30
-37
lines changed

3 files changed

+30
-37
lines changed

Cargo.lock

Lines changed: 23 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ edition = "2018"
77
[dependencies]
88
anyhow = "1.0"
99
async-trait = "0.1.24"
10+
ctrlc = "3.1"
1011
futures = "0.3.1"
1112
http = "0.2.0"
1213
hyper = "0.14"
1314
libc = "0.2.71"
1415
ring = "0.16"
1516
serde_json = "1.0"
16-
signal-hook = "0.3"
1717
smf = "0.1"
1818
structopt = "0.3"
1919
tar = "0.4"
@@ -45,10 +45,6 @@ features = [ "chrono", "uuid" ]
4545
version = "1.0"
4646
features = [ "derive" ]
4747

48-
[dependencies.signal-hook-tokio]
49-
version = "0.3"
50-
features = [ "futures-v0_3" ]
51-
5248
[dependencies.slog]
5349
version = "2.5"
5450
features = [ "max_level_trace", "release_max_level_debug" ]

src/bin/omicron_dev.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44

55
use anyhow::bail;
66
use anyhow::Context;
7-
use futures::stream::StreamExt;
87
use omicron::cmd::fatal;
98
use omicron::cmd::CmdError;
109
use omicron::dev_db;
11-
use signal_hook::consts::signal::SIGINT;
12-
use signal_hook_tokio::Signals;
1310
use std::path::PathBuf;
1411
use structopt::StructOpt;
1512

@@ -45,8 +42,11 @@ async fn cmd_db_run(args: &DbRunArgs) -> Result<(), anyhow::Error> {
4542
* before we've created resources that we want to have cleaned up on SIGINT
4643
* (e.g., the temporary directory created by the database starter).
4744
*/
48-
let signals = Signals::new(&[SIGINT]).expect("failed to wait for SIGINT");
49-
let mut signal_stream = signals.fuse();
45+
let (tx, mut rx) = tokio::sync::watch::channel(());
46+
ctrlc::set_handler(move || {
47+
tx.send(()).expect("internal error: failed to send CTRL-C message");
48+
})
49+
.expect("failed to wait for SIGINT");
5050

5151
/*
5252
* Now start CockroachDB. This process looks bureaucratic (create arg
@@ -102,9 +102,7 @@ async fn cmd_db_run(args: &DbRunArgs) -> Result<(), anyhow::Error> {
102102
(see error output above)"
103103
);
104104
}
105-
caught_signal = signal_stream.next() => {
106-
assert_eq!(caught_signal.unwrap(), SIGINT);
107-
105+
_ = rx.changed() => {
108106
/*
109107
* We don't have to do anything to trigger shutdown because the
110108
* shell will have delivered the same SIGINT that we got to the

0 commit comments

Comments
 (0)