Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SIGTERM support #12881

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading