Skip to content

Commit 7a01452

Browse files
authored
Add SIGTERM support (#12881)
1 parent b36f8da commit 7a01452

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

Crashlytics/Crashlytics/Controllers/FIRCLSMetricKitManager.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ - (NSString *)getSignalName:(NSNumber *)signalCode {
438438
return @"SIGSYS";
439439
case SIGTRAP:
440440
return @"SIGTRAP";
441+
case SIGTERM:
442+
return @"SIGTERM";
441443
default:
442444
return @"UNKNOWN";
443445
}

Crashlytics/Crashlytics/Handlers/FIRCLSMachException.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ exception_mask_t FIRCLSMachExceptionMaskForSignal(int signal) {
150150
return EXC_MASK_CRASH;
151151
case SIGFPE:
152152
return EXC_MASK_ARITHMETIC;
153+
case SIGTERM:
154+
return EXC_MASK_CRASH;
153155
}
154156

155157
return 0;

Crashlytics/Crashlytics/Handlers/FIRCLSSignal.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@
2121
#include <stdlib.h>
2222

2323
#if CLS_SIGNAL_SUPPORTED
24-
static const int FIRCLSFatalSignals[FIRCLSSignalCount] = {SIGABRT, SIGBUS, SIGFPE, SIGILL,
25-
SIGSEGV, SIGSYS, SIGTRAP};
24+
static const int FIRCLSFatalSignals[FIRCLSSignalCount] = {
25+
SIGABRT, SIGBUS, SIGFPE, SIGILL,
26+
SIGSEGV, SIGSYS, SIGTRAP,
27+
// SIGTERM can be caught and is usually sent by iOS and variants
28+
// when Apple wants to try and gracefully shutdown the app
29+
// before sending a SIGKILL (which can't be caught).
30+
// Some areas I've seen this happen are:
31+
// - When the OS updates an app.
32+
// - In some circumstances for Watchdog Events.
33+
// - Resource overuse (CPU, Disk, ...).
34+
SIGTERM};
2635

2736
#if CLS_USE_SIGALTSTACK
2837
static void FIRCLSSignalInstallAltStack(FIRCLSSignalReadContext *roContext);
@@ -237,6 +246,9 @@ void FIRCLSSignalNameLookup(int number, int code, const char **name, const char
237246
case SIGTRAP:
238247
*name = "SIGTRAP";
239248
break;
249+
case SIGTERM:
250+
*name = "SIGTERM";
251+
break;
240252
default:
241253
*name = "UNKNOWN";
242254
break;

Crashlytics/Crashlytics/Handlers/FIRCLSSignal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
#endif
3131

3232
#if CLS_SIGNAL_SUPPORTED
33-
#define FIRCLSSignalCount (7)
33+
// keep in sync with the list in _FIRCLSFatalSignals_.
34+
#define FIRCLSSignalCount (8)
3435

3536
typedef struct {
3637
const char* path;

0 commit comments

Comments
 (0)