File tree Expand file tree Collapse file tree 2 files changed +20
-19
lines changed
Expand file tree Collapse file tree 2 files changed +20
-19
lines changed Original file line number Diff line number Diff line change 11//! On-disk saved state.
22
33use crate :: model:: SavedState ;
4+ use crate :: util:: SignalTerminationGuard ;
45use anyhow:: { bail, Context , Result } ;
56use fn_error_context:: context;
67use fs2:: FileExt ;
@@ -9,25 +10,6 @@ use std::fs::File;
910use std:: io:: prelude:: * ;
1011use std:: path:: Path ;
1112
12- /// Suppress SIGTERM while active
13- // TODO: In theory we could record if we got SIGTERM and exit
14- // on drop, but in practice we don't care since we're going to exit anyways.
15- #[ derive( Debug ) ]
16- struct SignalTerminationGuard ( signal_hook_registry:: SigId ) ;
17-
18- impl SignalTerminationGuard {
19- pub ( crate ) fn new ( ) -> Result < Self > {
20- let signal = unsafe { signal_hook_registry:: register ( libc:: SIGTERM , || { } ) ? } ;
21- Ok ( Self ( signal) )
22- }
23- }
24-
25- impl Drop for SignalTerminationGuard {
26- fn drop ( & mut self ) {
27- signal_hook_registry:: unregister ( self . 0 ) ;
28- }
29- }
30-
3113impl SavedState {
3214 /// System-wide bootupd write lock (relative to sysroot).
3315 const WRITE_LOCK_PATH : & ' static str = "run/bootupd-lock" ;
Original file line number Diff line number Diff line change @@ -115,3 +115,22 @@ pub fn running_in_container() -> bool {
115115 }
116116 false
117117}
118+
119+ /// Suppress SIGTERM while active
120+ // TODO: In theory we could record if we got SIGTERM and exit
121+ // on drop, but in practice we don't care since we're going to exit anyways.
122+ #[ derive( Debug ) ]
123+ pub ( crate ) struct SignalTerminationGuard ( signal_hook_registry:: SigId ) ;
124+
125+ impl SignalTerminationGuard {
126+ pub ( crate ) fn new ( ) -> Result < Self > {
127+ let signal = unsafe { signal_hook_registry:: register ( libc:: SIGTERM , || { } ) ? } ;
128+ Ok ( Self ( signal) )
129+ }
130+ }
131+
132+ impl Drop for SignalTerminationGuard {
133+ fn drop ( & mut self ) {
134+ signal_hook_registry:: unregister ( self . 0 ) ;
135+ }
136+ }
You can’t perform that action at this time.
0 commit comments