Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit e27c431

Browse files
committed
Fix CLI is not disconnected on iOS exception
The code used to read only the first digit, but according to the documentation the signal code is a two-digit hexadecimal number With the current version of the runtime the signal that is raised is SIGABRT == 0x06
1 parent 901e91e commit e27c431

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

mobile/ios/device/ios-core.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,11 +1137,18 @@ class GDBSignalWatcher extends stream.Writable {
11371137

11381138
public _write(packet: any, encoding: string, callback: Function) {
11391139
try {
1140-
for (let i = 0; i < packet.length - 2; i++) {
1141-
if (packet[i] === getCharacterCodePoint("$") && (packet[i + 1] === getCharacterCodePoint("T") || packet[i + 1] === getCharacterCodePoint("S"))) {
1142-
// SIGKILL || SIGABRT
1143-
if (packet[i + 2] === getCharacterCodePoint("9") ||
1144-
packet[i + 2] === getCharacterCodePoint("6")) {
1140+
const dollarCodePoint = getCharacterCodePoint("$");
1141+
const TCodePoint = getCharacterCodePoint("T");
1142+
const SCodePoint = getCharacterCodePoint("S");
1143+
// The reply packages take the following form (the space in the reply templates is included for clarity)
1144+
// ‘S AA’ or ‘T AA n1:r1;n2:r2;...’ meaning that the program received signal number AA (a two-digit hexadecimal number)
1145+
for (let i = 0; i < packet.length - 3; i++) {
1146+
if (packet[i] === dollarCodePoint && (packet[i + 1] === TCodePoint || packet[i + 1] === SCodePoint)) {
1147+
let signalHex = packet.toString("ascii", i + 2, i + 4);
1148+
let signalDecimal = parseInt(signalHex, 16);
1149+
1150+
// SIGTRAP || SIGABRT || SIGKILL || SIGSEGV || EXC_BAD_ACCESS
1151+
if (signalDecimal === 5 || signalDecimal === 6 || signalDecimal === 9 || signalDecimal === 11 || signalDecimal === 145) {
11451152
process.exit(1);
11461153
}
11471154
}

0 commit comments

Comments
 (0)