|
4 | 4 |
|
5 | 5 | use anyhow::bail;
|
6 | 6 | use anyhow::Context;
|
7 |
| -use futures::stream::StreamExt; |
8 | 7 | use omicron::cmd::fatal;
|
9 | 8 | use omicron::cmd::CmdError;
|
10 | 9 | use omicron::dev_db;
|
11 |
| -use signal_hook::consts::signal::SIGINT; |
12 |
| -use signal_hook_tokio::Signals; |
13 | 10 | use std::path::PathBuf;
|
14 | 11 | use structopt::StructOpt;
|
15 | 12 |
|
@@ -45,8 +42,11 @@ async fn cmd_db_run(args: &DbRunArgs) -> Result<(), anyhow::Error> {
|
45 | 42 | * before we've created resources that we want to have cleaned up on SIGINT
|
46 | 43 | * (e.g., the temporary directory created by the database starter).
|
47 | 44 | */
|
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"); |
50 | 50 |
|
51 | 51 | /*
|
52 | 52 | * Now start CockroachDB. This process looks bureaucratic (create arg
|
@@ -102,9 +102,7 @@ async fn cmd_db_run(args: &DbRunArgs) -> Result<(), anyhow::Error> {
|
102 | 102 | (see error output above)"
|
103 | 103 | );
|
104 | 104 | }
|
105 |
| - caught_signal = signal_stream.next() => { |
106 |
| - assert_eq!(caught_signal.unwrap(), SIGINT); |
107 |
| - |
| 105 | + _ = rx.changed() => { |
108 | 106 | /*
|
109 | 107 | * We don't have to do anything to trigger shutdown because the
|
110 | 108 | * shell will have delivered the same SIGINT that we got to the
|
|
0 commit comments