pub struct CrashHandler;
Expand description
A Linux/Android signal handler
Implementations§
Source§impl CrashHandler
impl CrashHandler
Sourcepub fn attach(on_crash: Box<dyn CrashEvent>) -> Result<Self, Error>
pub fn attach(on_crash: Box<dyn CrashEvent>) -> Result<Self, Error>
Attaches the signal handler.
The provided callback will be invoked if a signal is caught, providing a
crate::CrashContext
with the details of the thread where the
signal was raised.
The callback runs in a compromised context, so it is highly recommended to not perform actions that may fail due to corrupted state that caused or is a symptom of the original signal. This includes doing heap allocations from the same allocator as the crashing code.
Sourcepub fn detach(self)
pub fn detach(self)
Detaches the handler.
This is done automatically when this CrashHandler
is dropped.
Sourcepub fn set_ptracer(&self, pid: Option<u32>)
pub fn set_ptracer(&self, pid: Option<u32>)
Set the process that is allowed to perform ptrace
operations on the
current process.
If you want to write a minidump from a child/external process when a crash occurs in this process, you can use this method to set that process as the only process allowed to use ptrace on this process.
The process set by this method will be used by calling
prctl(PR_SET_PTRACER, <the pid you want to ptrace this process>, ...)
before handing off control to your user callback, presumably to trigger
dumping of your process via the specified process. By default if this
method is not called, PR_SET_PTRACER_ANY
is used to allow any process
to dump the current process.
Note that this is only needed if /proc/sys/kernel/yama/ptrace_scope
is 1 “restricted ptrace”, but there is no harm in setting this if it is
in another mode.
See https://www.kernel.org/doc/Documentation/security/Yama.txt for the full documentation.
Sourcepub fn simulate_signal(&self, signal: u32) -> CrashEventResult
pub fn simulate_signal(&self, signal: u32) -> CrashEventResult
Sends the specified user signal.