File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed
Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -114,17 +114,15 @@ func (d *Discovery) List() ([]*BoardPort, error) {
114114
115115// Close stops the Discovery and free the resources
116116func (d * Discovery ) Close () error {
117- // TODO: Send QUIT for safe close or terminate process after a small timeout
118- if err := d .in .Close (); err != nil {
119- return fmt .Errorf ("closing stdin pipe: %s" , err )
120- }
121- if err := d .out .Close (); err != nil {
122- return fmt .Errorf ("closing stdout pipe: %s" , err )
123- }
124- if d .cmd != nil {
125- d .cmd .Process .Kill ()
126- }
127- return nil
117+ _ , _ = d .in .Write ([]byte ("QUIT\n " ))
118+ _ = d .in .Close ()
119+ _ = d .out .Close ()
120+ timer := time .AfterFunc (time .Second , func () {
121+ _ = d .cmd .Process .Kill ()
122+ })
123+ err := d .cmd .Wait ()
124+ _ = timer .Stop ()
125+ return err
128126}
129127
130128// ExtractDiscoveriesFromPlatforms returns all Discovery from all the installed platforms.
You can’t perform that action at this time.
0 commit comments