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

Commit 5df41b1

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 5df41b1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

mobile/ios/device/ios-core.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,11 +1137,15 @@ 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++) {
1140+
// The reply packages take the following form (the space in the reply templates is included for clarity)
1141+
// ‘S AA’ or ‘T AA n1:r1;n2:r2;...’ meaning that the program received signal number AA (a two-digit hexadecimal number)
1142+
for (let i = 0; i < packet.length - 3; i++) {
11411143
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")) {
1144+
let signalHex = packet.toString("ascii", i + 2, i + 4);
1145+
let signalDecimal = parseInt(signalHex, 16);
1146+
1147+
// SIGTRAP || SIGABRT || SIGKILL || SIGSEGV || EXC_BAD_ACCESS
1148+
if (signalDecimal === 5 || signalDecimal === 6 || signalDecimal === 9 || signalDecimal === 11 || signalDecimal === 145) {
11451149
process.exit(1);
11461150
}
11471151
}

0 commit comments

Comments
 (0)