mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 02:35:31 +00:00
PanicSentinel: send SIGTERM only once
This commit is contained in:
parent
b61b136b0c
commit
10997596fa
1 changed files with 8 additions and 6 deletions
|
|
@ -55,13 +55,15 @@ pub struct PanicSentinel(Arc<AtomicBool>);
|
||||||
|
|
||||||
impl Drop for PanicSentinel {
|
impl Drop for PanicSentinel {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.0.store(true, Ordering::SeqCst);
|
let already_triggered = self.0.fetch_or(true, Ordering::SeqCst);
|
||||||
|
|
||||||
if unsafe { libc::raise(15) } == -1 {
|
if !already_triggered {
|
||||||
panic!(
|
if unsafe { libc::raise(15) } == -1 {
|
||||||
"Could not raise SIGTERM: {:#}",
|
panic!(
|
||||||
::std::io::Error::last_os_error()
|
"Could not raise SIGTERM: {:#}",
|
||||||
)
|
::std::io::Error::last_os_error()
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue