diff --git a/lib/services/ios-debug-service.ts b/lib/services/ios-debug-service.ts index 22b01dffaf..26105413af 100644 --- a/lib/services/ios-debug-service.ts +++ b/lib/services/ios-debug-service.ts @@ -78,20 +78,31 @@ class IOSDebugService extends DebugServiceBase implements IPlatformDebugService } _.forEach(this._sockets, socket => socket.destroy()); + this._sockets = []; if (this._lldbProcess) { this._lldbProcess.stdin.write("process detach\n"); - this._lldbProcess.kill(); + + await this.killProcess(this._lldbProcess); this._lldbProcess = undefined; } if (this._childProcess) { - this._childProcess.kill(); + await this.killProcess(this._childProcess); this._childProcess = undefined; } } + private async killProcess(childProcess: ChildProcess): Promise { + if (childProcess) { + return new Promise((resolve, reject) => { + childProcess.on("close", resolve); + childProcess.kill(); + }); + } + } + private async emulatorDebugBrk(debugData: IDebugData, debugOptions: IDebugOptions): Promise { let args = debugOptions.debugBrk ? "--nativescript-debug-brk" : "--nativescript-debug-start"; let child_process = await this.$iOSEmulatorServices.runApplicationOnEmulator(debugData.pathToAppPackage, {