diff --git a/aquatic_common/src/lib.rs b/aquatic_common/src/lib.rs index a5f25aa..c3cf62e 100644 --- a/aquatic_common/src/lib.rs +++ b/aquatic_common/src/lib.rs @@ -55,14 +55,16 @@ pub struct PanicSentinel(Arc); impl Drop for PanicSentinel { fn drop(&mut self) { - let already_triggered = self.0.fetch_or(true, Ordering::SeqCst); + if ::std::thread::panicking() { + let already_triggered = self.0.fetch_or(true, Ordering::SeqCst); - if !already_triggered { - if unsafe { libc::raise(15) } == -1 { - panic!( - "Could not raise SIGTERM: {:#}", - ::std::io::Error::last_os_error() - ) + if !already_triggered { + if unsafe { libc::raise(15) } == -1 { + panic!( + "Could not raise SIGTERM: {:#}", + ::std::io::Error::last_os_error() + ) + } } } }