Skip to content

Commit

Permalink
Add SIGTERM support (#12881)
Browse files Browse the repository at this point in the history
  • Loading branch information
naftaly authored May 1, 2024
1 parent b36f8da commit 7a01452
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Crashlytics/Crashlytics/Controllers/FIRCLSMetricKitManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ - (NSString *)getSignalName:(NSNumber *)signalCode {
return @"SIGSYS";
case SIGTRAP:
return @"SIGTRAP";
case SIGTERM:
return @"SIGTERM";
default:
return @"UNKNOWN";
}
Expand Down
2 changes: 2 additions & 0 deletions Crashlytics/Crashlytics/Handlers/FIRCLSMachException.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ exception_mask_t FIRCLSMachExceptionMaskForSignal(int signal) {
return EXC_MASK_CRASH;
case SIGFPE:
return EXC_MASK_ARITHMETIC;
case SIGTERM:
return EXC_MASK_CRASH;
}

return 0;
Expand Down
16 changes: 14 additions & 2 deletions Crashlytics/Crashlytics/Handlers/FIRCLSSignal.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@
#include <stdlib.h>

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

#if CLS_USE_SIGALTSTACK
static void FIRCLSSignalInstallAltStack(FIRCLSSignalReadContext *roContext);
Expand Down Expand Up @@ -237,6 +246,9 @@ void FIRCLSSignalNameLookup(int number, int code, const char **name, const char
case SIGTRAP:
*name = "SIGTRAP";
break;
case SIGTERM:
*name = "SIGTERM";
break;
default:
*name = "UNKNOWN";
break;
Expand Down
3 changes: 2 additions & 1 deletion Crashlytics/Crashlytics/Handlers/FIRCLSSignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
#endif

#if CLS_SIGNAL_SUPPORTED
#define FIRCLSSignalCount (7)
// keep in sync with the list in _FIRCLSFatalSignals_.
#define FIRCLSSignalCount (8)

typedef struct {
const char* path;
Expand Down

0 comments on commit 7a01452

Please sign in to comment.