File tree Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Original file line number Diff line number Diff line change @@ -238,24 +238,21 @@ func (disc *Client) runProcess() error {
238238 return nil
239239}
240240
241- func (disc * Client ) killProcess () error {
241+ func (disc * Client ) killProcess () {
242242 disc .statusMutex .Lock ()
243243 defer disc .statusMutex .Unlock ()
244244
245245 disc .logger .Infof ("Killing discovery process" )
246- if disc .process != nil {
247- if err := disc .process .Kill (); err != nil {
246+ if process := disc .process ; process != nil {
247+ disc .process = nil
248+ if err := process .Kill (); err != nil {
248249 disc .logger .Errorf ("Killing discovery process: %v" , err )
249- return err
250250 }
251- if err := disc . process .Wait (); err != nil {
251+ if err := process .Wait (); err != nil {
252252 disc .logger .Errorf ("Waiting discovery process termination: %v" , err )
253- return err
254253 }
255- disc .process = nil
256254 }
257255 disc .logger .Infof ("Discovery process killed" )
258- return nil
259256}
260257
261258// Run starts the discovery executable process and sends the HELLO command to the discovery to agree on the
@@ -273,11 +270,7 @@ func (disc *Client) Run() (err error) {
273270 if err == nil {
274271 return
275272 }
276- if err := disc .killProcess (); err != nil {
277- // Log failure to kill the process, ideally that should never happen
278- // but it's best to know it if it does
279- disc .logger .Errorf ("Killing discovery after unsuccessful start: %s" , err )
280- }
273+ disc .killProcess ()
281274 }()
282275
283276 if err = disc .sendCommand ("HELLO 1 \" arduino-cli " + disc .userAgent + "\" \n " ); err != nil {
You can’t perform that action at this time.
0 commit comments