@@ -23,10 +23,11 @@ let portToBind = 0;
2323
2424export class DevTools implements vs . Disposable {
2525 private devToolsStatusBarItem = vs . window . createStatusBarItem ( vs . StatusBarAlignment . Right , 100 ) ;
26- private proc : child_process . ChildProcess ;
26+ private proc : child_process . ChildProcess | undefined ;
27+ private realPid : number | undefined ;
2728 /// Resolves to the DevTools URL. This is created immediately when a new process is being spawned so that
2829 /// concurrent launches can wait on the same promise.
29- private devtoolsUrl : Thenable < string > ;
30+ private devtoolsUrl : Thenable < string > | undefined ;
3031
3132 constructor ( private sdks : Sdks , private analytics : Analytics , private pubGlobal : PubGlobal ) { }
3233
@@ -85,6 +86,7 @@ export class DevTools implements vs.Disposable {
8586 const evt = JSON . parse ( output ) ;
8687 if ( evt . method === "server.started" ) {
8788 portToBind = evt . params . port ;
89+ this . realPid = evt . params . pid ;
8890 resolve ( `http://${ evt . params . host } :${ evt . params . port } /` ) ;
8991 }
9092 } catch {
@@ -113,9 +115,18 @@ export class DevTools implements vs.Disposable {
113115
114116 public dispose ( ) : void {
115117 this . devToolsStatusBarItem . dispose ( ) ;
116- this . devtoolsUrl = null ;
118+ this . devtoolsUrl = undefined ;
117119 if ( this . proc && ! this . proc . killed ) {
118120 this . proc . kill ( ) ;
119121 }
122+ if ( this . realPid ) {
123+ try {
124+ process . kill ( this . realPid ) ;
125+ } catch ( e ) {
126+ // Sometimes this process will have already gone away (eg. the initial kill() worked)
127+ // so logging here just results in lots of useless info.
128+ }
129+ this . realPid = undefined ;
130+ }
120131 }
121132}
0 commit comments