Struct CrashHandler

Source
pub struct CrashHandler;
Expand description

A Linux/Android signal handler

Implementations§

Source§

impl CrashHandler

Source

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.

Source

pub fn detach(self)

Detaches the handler.

This is done automatically when this CrashHandler is dropped.

Source

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.

Source

pub fn simulate_signal(&self, signal: u32) -> CrashEventResult

Sends the specified user signal.

Trait Implementations§

Source§

impl Drop for CrashHandler

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.