SIGABRT
signal handler and raiser for ZZ
Add this to your zz.toml
file:
[dependencies]
abort_signal = "*"
[repos]
abort_signal = "git+ssh://[email protected]/zzmodules/abort-signal.git"
using abort_signal
Raises the abort signal (SIGABRT
). If a abort signal callback function
was set, then the raised signal will be caught by it. The default behaviour
will be that of the native abort()
function when the SIGABRT
handler is
raises. If the SIGABRT
signal is caught by another function not set by this
module, then it will be caught there. This function will return true
if the
SIGABRT
signal was raised and caught successfully. Check the error
if the caller of this function gets a false
return value.
using abort_signal::{ abort }
using err
fn main() -> int {
new+4096 mut error = err::make();
if abort(&error) {
// failed to raise an abort signal
error.elog();
}
}
Sets the abort signal (SIGABRT
) callback handler function.
using abort_signal::{ abort, set_abort_callback }
using err
fn onabort() {
// gracefully abort
}
fn main() -> int {
new+4096 mut error = err::make();
set_abort_callback(onabort);
if abort(&error) {
// failed to raise an abort signal
error.elog();
}
return 0;
}
Removes the abort signal (SIGABRT
) callback handler function.
abort_signal::remove_abort_callback();
MIT