@@ -12,7 +12,10 @@ use spfs::Error;
12
12
use spfs_cli_common as cli;
13
13
use spfs_cli_common:: CommandName ;
14
14
use tokio:: io:: AsyncReadExt ;
15
+ #[ cfg( unix) ]
15
16
use tokio:: signal:: unix:: { signal, SignalKind } ;
17
+ #[ cfg( windows) ]
18
+ use tokio:: signal:: windows:: ctrl_c;
16
19
use tokio:: time:: timeout;
17
20
18
21
fn main ( ) -> Result < ( ) > {
@@ -86,11 +89,10 @@ impl CmdMonitor {
86
89
rt. block_on ( self . wait_for_ready ( ) ) ;
87
90
// clean up this runtime and all other threads before detaching
88
91
drop ( rt) ;
89
-
92
+ # [ cfg ( unix ) ]
90
93
nix:: unistd:: daemon ( self . no_chdir , self . no_close )
91
94
. into_diagnostic ( )
92
95
. wrap_err ( "Failed to daemonize the monitor process" ) ?;
93
-
94
96
#[ cfg( feature = "sentry" ) ]
95
97
{
96
98
// Initialize sentry after the call to `daemon` so it is safe for
@@ -142,12 +144,27 @@ impl CmdMonitor {
142
144
}
143
145
144
146
pub async fn run_async ( & mut self ) -> Result < i32 > {
147
+ #[ cfg( unix) ]
145
148
let mut interrupt = signal ( SignalKind :: interrupt ( ) )
146
149
. map_err ( |err| Error :: process_spawn_error ( "signal()" , err, None ) ) ?;
150
+ #[ cfg( unix) ]
151
+ let interrupt = signal ( SignalKind :: interrupt ( ) )
152
+ . map_err ( |err| Error :: process_spawn_error ( "signal()" , err, None ) ) ?;
153
+ #[ cfg( windows) ]
154
+ let mut interrupt = ctrl_c ( )
155
+ . map_err ( |err| Error :: process_spawn_error ( "ctrl_c()" , err, None ) ) ?;
156
+ #[ cfg( unix) ]
147
157
let mut quit = signal ( SignalKind :: quit ( ) )
148
158
. map_err ( |err| Error :: process_spawn_error ( "signal()" , err, None ) ) ?;
159
+ #[ cfg( windows) ]
160
+ let mut quit = ctrl_c ( )
161
+ . map_err ( |err| Error :: process_spawn_error ( "ctrl_c()" , err, None ) ) ?;
162
+ #[ cfg( unix) ]
149
163
let mut terminate = signal ( SignalKind :: terminate ( ) )
150
164
. map_err ( |err| Error :: process_spawn_error ( "signal()" , err, None ) ) ?;
165
+ #[ cfg( windows) ]
166
+ let mut terminate = ctrl_c ( )
167
+ . map_err ( |err| Error :: process_spawn_error ( "ctrl_c()" , err, None ) ) ?;
151
168
152
169
let repo = spfs:: open_repository ( & self . runtime_storage ) . await ?;
153
170
let storage = spfs:: runtime:: Storage :: new ( repo) ?;
0 commit comments