Skip to content

Commit f7004e3

Browse files
Merge pull request #96 from telerik/vladimirov/fix-killing-process
Fix killing simctl process capturing the kill signal without sending to parent
2 parents 0b52a9c + 4ec1d9f commit f7004e3

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

lib/simctl.ts

+16-7
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ export class Simctl implements ISimctl {
3232
}
3333

3434
public install(deviceId: string, applicationPath: string): void {
35-
return this.simctlExec("install", [deviceId, applicationPath]);
35+
this.simctlExec("install", [deviceId, applicationPath]);
3636
}
3737

3838
public uninstall(deviceId: string, appIdentifier: string, opts?: any): void {
39-
return this.simctlExec("uninstall", [deviceId, appIdentifier], opts);
39+
this.simctlExec("uninstall", [deviceId, appIdentifier], opts);
4040
}
4141

4242
public notifyPost(deviceId: string, notification: string): void {
43-
return this.simctlExec("notify_post", [deviceId, notification]);
43+
this.simctlExec("notify_post", [deviceId, notification]);
4444
}
4545

4646
public getAppContainer(deviceId: string, appIdentifier: string): string {
@@ -120,11 +120,20 @@ export class Simctl implements ISimctl {
120120
return devices;
121121
}
122122

123-
private simctlExec(command: string, args: string[], opts?: any): any {
124-
let result = childProcess.spawnSync("xcrun", ["simctl", command].concat(args), opts);
125-
if(result && result.stdout) {
126-
return result.stdout.toString().trim();
123+
private simctlExec(command: string, args: string[], opts?: any): string {
124+
const result = childProcess.spawnSync("xcrun", ["simctl", command].concat(args), opts);
125+
if (result) {
126+
if (result.signal) {
127+
// In some cases, sending Ctrl + C (SIGINT) is handled by the simctl itself and spawnSync finishes, but the SIGINT does not stop current process.
128+
// In order to ensure the same signal is sent to the caller (CLI for example), send the signal manually:
129+
process.send(result.signal);
130+
}
131+
132+
if (result.stdout) {
133+
return result.stdout.toString().trim();
134+
}
127135
}
136+
128137
return '';
129138
}
130139
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ios-sim-portable",
3-
"version": "3.1.2",
3+
"version": "3.1.3",
44
"description": "",
55
"main": "./lib/ios-sim.js",
66
"scripts": {

0 commit comments

Comments
 (0)