@@ -16,7 +16,7 @@ import { ArduinoDaemon, NotificationServiceServer } from '../common/protocol';
16
16
import { CLI_CONFIG } from './cli-config' ;
17
17
import { getExecPath } from './exec-util' ;
18
18
import { SettingsReader } from './settings-reader' ;
19
- // import { ProcessUtils } from '@theia/core/lib/node/process-utils';
19
+ import { ProcessUtils } from '@theia/core/lib/node/process-utils' ;
20
20
21
21
@injectable ( )
22
22
export class ArduinoDaemonImpl
@@ -35,8 +35,8 @@ export class ArduinoDaemonImpl
35
35
@inject ( SettingsReader )
36
36
private readonly settingsReader : SettingsReader ;
37
37
38
- // @inject (ProcessUtils)
39
- // private readonly processUtils: ProcessUtils;
38
+ @inject ( ProcessUtils )
39
+ private readonly processUtils : ProcessUtils ;
40
40
41
41
private readonly toDispose = new DisposableCollection ( ) ;
42
42
private readonly onDaemonStartedEmitter = new Emitter < string > ( ) ;
@@ -89,8 +89,14 @@ export class ArduinoDaemonImpl
89
89
90
90
this . toDispose . pushAll ( [
91
91
Disposable . create ( ( ) => {
92
- daemon . kill ( ) ;
93
- this . fireDaemonStopped ( ) ;
92
+ if ( daemon . pid ) {
93
+ this . processUtils . terminateProcessTree ( daemon . pid ) ;
94
+ this . fireDaemonStopped ( ) ;
95
+ } else {
96
+ throw new Error (
97
+ 'The CLI Daemon process does not have a PID. IDE2 could not stop the CLI daemon.'
98
+ ) ;
99
+ }
94
100
} ) ,
95
101
] ) ;
96
102
this . fireDaemonStarted ( port ) ;
0 commit comments