aboutsummaryrefslogtreecommitdiff
path: root/src/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.rs')
-rw-r--r--src/utils.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/utils.rs b/src/utils.rs
index 7c71deb..cb9b65e 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -1,6 +1,22 @@
use core::alloc::Layout;
use core::mem;
+/// Aborts the process.
+///
+/// To abort, this function simply panics while panicking.
+pub(crate) fn abort() -> ! {
+ struct Panic;
+
+ impl Drop for Panic {
+ fn drop(&mut self) {
+ panic!("aborting the process");
+ }
+ }
+
+ let _panic = Panic;
+ panic!("aborting the process");
+}
+
/// Calls a function and aborts if it panics.
///
/// This is useful in unsafe code where we can't recover from panics.
@@ -10,7 +26,7 @@ pub(crate) fn abort_on_panic<T>(f: impl FnOnce() -> T) -> T {
impl Drop for Bomb {
fn drop(&mut self) {
- unsafe { libc::abort() }
+ abort();
}
}