@@ -2,11 +2,13 @@ import * as path from "path";
2
2
import * as net from "net" ;
3
3
import Future = require( "fibers/future" ) ;
4
4
import { sleep } from "../common/helpers" ;
5
+ import { ChildProcess } from "child_process" ;
5
6
6
7
class AndroidDebugService implements IDebugService {
7
8
private static DEFAULT_NODE_INSPECTOR_URL = "http://127.0.0.1:8080/debug" ;
8
9
9
10
private _device : Mobile . IAndroidDevice = null ;
11
+ private _debuggerClientProcess : ChildProcess ;
10
12
11
13
constructor ( private $devicesService : Mobile . IDevicesService ,
12
14
private $platformService : IPlatformService ,
@@ -19,6 +21,7 @@ class AndroidDebugService implements IDebugService {
19
21
private $errors : IErrors ,
20
22
private $opener : IOpener ,
21
23
private $config : IConfiguration ,
24
+ private $processService : IProcessService ,
22
25
private $androidDeviceDiscovery : Mobile . IDeviceDiscovery ) { }
23
26
24
27
public get platform ( ) { return "android" ; }
@@ -187,6 +190,7 @@ class AndroidDebugService implements IDebugService {
187
190
}
188
191
189
192
public debugStop ( ) : IFuture < void > {
193
+ this . stopDebuggerClient ( ) ;
190
194
return Future . fromResult ( ) ;
191
195
}
192
196
@@ -237,10 +241,18 @@ class AndroidDebugService implements IDebugService {
237
241
let nodeInspectorModuleFilePath = require . resolve ( "node-inspector" ) ;
238
242
let nodeInspectorModuleDir = path . dirname ( nodeInspectorModuleFilePath ) ;
239
243
let nodeInspectorFullPath = path . join ( nodeInspectorModuleDir , "bin" , "inspector" ) ;
240
- this . $childProcess . spawn ( process . argv [ 0 ] , [ nodeInspectorFullPath , "--debug-port" , port . toString ( ) ] , { stdio : "ignore" , detached : true } ) ;
244
+ this . _debuggerClientProcess = this . $childProcess . spawn ( process . argv [ 0 ] , [ nodeInspectorFullPath , "--debug-port" , port . toString ( ) ] , { stdio : "ignore" , detached : true } ) ;
245
+ this . $processService . attachToProcessExitSignals ( this , this . debugStop ) ;
241
246
} ) . future < void > ( ) ( ) ;
242
247
}
243
248
249
+ private stopDebuggerClient ( ) : void {
250
+ if ( this . _debuggerClientProcess ) {
251
+ this . _debuggerClientProcess . kill ( ) ;
252
+ this . _debuggerClientProcess = null ;
253
+ }
254
+ }
255
+
244
256
private openDebuggerClient ( url : string ) : void {
245
257
let defaultDebugUI = "chrome" ;
246
258
if ( this . $hostInfo . isDarwin ) {
0 commit comments