Skip to content

Commit 7c6a47f

Browse files
committed
Disable core files and tombstones
1 parent dec81ab commit 7c6a47f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Sources/Testing/ExitTests/ExitTest.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,20 @@ extension ExitTest {
226226
var rl = rlimit(rlim_cur: 0, rlim_max: 0)
227227
_ = setrlimit(RLIMIT_CORE, &rl)
228228
#elseif os(Android)
229-
// TODO: "tombstoned_intercept"?
229+
// Android inherits the RLIMIT_CORE=1 special case from Linux.
230+
// SEE: https://android.googlesource.com/kernel/common/+/refs/heads/android-mainline/fs/coredump.c#978
231+
var rl = rlimit(rlim_cur: 1, rlim_max: 1)
232+
_ = setrlimit(CInt(RLIMIT_CORE.rawValue), &rl)
233+
234+
// In addition, Android installs signal handlers in native processes that
235+
// cause the system to generate "tombstone" files. Suppress those too by
236+
// resetting all signal handlers to SIG_DFL. debuggerd_register_handlers()
237+
// is not exported, so we must manually walk all the signals it handles.
238+
// SEE: https://android.googlesource.com/platform/system/core/+/main/debuggerd/include/debuggerd/handler.h#81
239+
let BIONIC_SIGNAL_DEBUGGER = __SIGRTMIN + 3
240+
for sig in [SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV, SIGSTKFLT, SIGSYS, SIGTRAP, BIONIC_SIGNAL_DEBUGGER] {
241+
_ = signal(sig, SIG_DFL)
242+
}
230243
#elseif os(Windows)
231244
// On Windows, similarly disable Windows Error Reporting and the Windows
232245
// Error Reporting UI. Note we expect to be the first component to call

0 commit comments

Comments
 (0)