Skip to content

Commit b3fe9df

Browse files
author
Tsvetan Raikov
committed
Fixed: Ctrl+C not working on Android debug+watch
1 parent e38c09c commit b3fe9df

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/services/android-debug-service.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import * as path from "path";
22
import * as net from "net";
33
import Future = require("fibers/future");
44
import { sleep } from "../common/helpers";
5+
import {ChildProcess} from "child_process";
56

67
class AndroidDebugService implements IDebugService {
78
private static DEFAULT_NODE_INSPECTOR_URL = "http://127.0.0.1:8080/debug";
89

910
private _device: Mobile.IAndroidDevice = null;
11+
private _debuggerClientProcess: ChildProcess;
1012

1113
constructor(private $devicesService: Mobile.IDevicesService,
1214
private $platformService: IPlatformService,
@@ -19,6 +21,7 @@ class AndroidDebugService implements IDebugService {
1921
private $errors: IErrors,
2022
private $opener: IOpener,
2123
private $config: IConfiguration,
24+
private $processService: IProcessService,
2225
private $androidDeviceDiscovery: Mobile.IDeviceDiscovery) { }
2326

2427
public get platform() { return "android"; }
@@ -187,6 +190,7 @@ class AndroidDebugService implements IDebugService {
187190
}
188191

189192
public debugStop(): IFuture<void> {
193+
this.stopDebuggerClient();
190194
return Future.fromResult();
191195
}
192196

@@ -232,15 +236,24 @@ class AndroidDebugService implements IDebugService {
232236
}
233237
}
234238

239+
235240
private startDebuggerClient(port: Number): IFuture<void> {
236241
return (() => {
237242
let nodeInspectorModuleFilePath = require.resolve("node-inspector");
238243
let nodeInspectorModuleDir = path.dirname(nodeInspectorModuleFilePath);
239244
let nodeInspectorFullPath = path.join(nodeInspectorModuleDir, "bin", "inspector");
240-
this.$childProcess.spawn(process.argv[0], [nodeInspectorFullPath, "--debug-port", port.toString()], { stdio: "ignore", detached: true });
245+
this._debuggerClientProcess = this.$childProcess.spawn(process.argv[0], [nodeInspectorFullPath, "--debug-port", port.toString()], { stdio: "ignore", detached: true });
246+
this.$processService.attachToProcessExitSignals(this, this.debugStop);
241247
}).future<void>()();
242248
}
243249

250+
private stopDebuggerClient(): void {
251+
if (this._debuggerClientProcess) {
252+
this._debuggerClientProcess.kill();
253+
this._debuggerClientProcess = null;
254+
}
255+
}
256+
244257
private openDebuggerClient(url: string): void {
245258
let defaultDebugUI = "chrome";
246259
if (this.$hostInfo.isDarwin) {

0 commit comments

Comments
 (0)