@@ -157,22 +157,25 @@ impl FlycheckActor {
157
157
while let Some ( event) = self . next_event ( & inbox) {
158
158
match event {
159
159
Event :: Restart ( Restart ) => {
160
- // Drop and cancel the previously spawned process
161
- self . cargo_handle . take ( ) ;
160
+ if let Some ( cargo_handle) = self . cargo_handle . take ( ) {
161
+ // Cancel the previously spawned process
162
+ cargo_handle. cancel ( ) ;
163
+ }
162
164
while let Ok ( Restart ) = inbox. recv_timeout ( Duration :: from_millis ( 50 ) ) { }
163
165
164
166
self . cancel_check_process ( ) ;
165
167
166
168
let command = self . check_command ( ) ;
167
- let command_f = format ! ( "restart flycheck {command:?}" ) ;
169
+ let command_f = format ! ( "{command:?}" ) ;
170
+ tracing:: debug!( ?command, "will restart flycheck" ) ;
168
171
match CargoHandle :: spawn ( command) {
169
172
Ok ( cargo_handle) => {
170
- tracing:: info! ( "{}" , command_f ) ;
173
+ tracing:: debug! ( %command_f , "did restart flycheck" ) ;
171
174
self . cargo_handle = Some ( cargo_handle) ;
172
175
self . progress ( Progress :: DidStart ) ;
173
176
}
174
- Err ( e ) => {
175
- tracing:: error!( "{ command_f} failed: {e:?}" , ) ;
177
+ Err ( error ) => {
178
+ tracing:: error!( % command_f, %error , " failed to restart flycheck" ) ;
176
179
}
177
180
}
178
181
}
@@ -289,7 +292,13 @@ impl CargoHandle {
289
292
Ok ( CargoHandle { child, thread, receiver } )
290
293
}
291
294
292
- fn join ( self ) -> io:: Result < ( ) > {
295
+ fn cancel ( mut self ) {
296
+ let _ = self . child . kill ( ) ;
297
+ let _ = self . child . wait ( ) ;
298
+ }
299
+
300
+ fn join ( mut self ) -> io:: Result < ( ) > {
301
+ let _ = self . child . kill ( ) ;
293
302
let exit_status = self . child . wait ( ) ?;
294
303
let ( read_at_least_one_message, error) = self . thread . join ( ) ?;
295
304
if read_at_least_one_message || exit_status. success ( ) {
0 commit comments