@@ -157,22 +157,25 @@ impl FlycheckActor {
157157 while let Some ( event) = self . next_event ( & inbox) {
158158 match event {
159159 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+ }
162164 while let Ok ( Restart ) = inbox. recv_timeout ( Duration :: from_millis ( 50 ) ) { }
163165
164166 self . cancel_check_process ( ) ;
165167
166168 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" ) ;
168171 match CargoHandle :: spawn ( command) {
169172 Ok ( cargo_handle) => {
170- tracing:: info! ( "{}" , command_f ) ;
173+ tracing:: debug! ( %command_f , "did restart flycheck" ) ;
171174 self . cargo_handle = Some ( cargo_handle) ;
172175 self . progress ( Progress :: DidStart ) ;
173176 }
174- Err ( e ) => {
175- tracing:: error!( "{ command_f} failed: {e:?}" , ) ;
177+ Err ( error ) => {
178+ tracing:: error!( % command_f, %error , " failed to restart flycheck" ) ;
176179 }
177180 }
178181 }
@@ -289,7 +292,13 @@ impl CargoHandle {
289292 Ok ( CargoHandle { child, thread, receiver } )
290293 }
291294
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 ( ) ;
293302 let exit_status = self . child . wait ( ) ?;
294303 let ( read_at_least_one_message, error) = self . thread . join ( ) ?;
295304 if read_at_least_one_message || exit_status. success ( ) {
0 commit comments