File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 99 - the MSRV is now defined as 1.82
1010
1111 ### Fixed
12+
13+ - fixed ` booted ` to return ` Ok(false) ` when not running under systemd
1214 - fixed ` watchdog_enabled ` to handle missing ` WATCHDOG_PID `
1315
1416## [ 0.4.5] - 2025-01-18
Original file line number Diff line number Diff line change @@ -131,11 +131,18 @@ impl NotifyState<'_> {
131131/// # Example
132132///
133133/// ```no_run
134- /// let _ = sd_notify::booted();
134+ /// match sd_notify::booted() {
135+ /// Ok(true) => { println!("System is booted under systemd")},
136+ /// Ok(false) => { println!("System is not booted under systemd")},
137+ /// Err(e) => { println!("Error: {}", e)},
138+ /// }
135139/// ```
136140pub fn booted ( ) -> io:: Result < bool > {
137- let m = fs:: symlink_metadata ( "/run/systemd/system" ) ?;
138- Ok ( m. is_dir ( ) )
141+ match fs:: symlink_metadata ( "/run/systemd/system" ) {
142+ Ok ( m) => Ok ( m. is_dir ( ) ) ,
143+ Err ( e) if matches ! ( e. kind( ) , ErrorKind :: NotFound ) => Ok ( false ) ,
144+ Err ( e) => Err ( e) ,
145+ }
139146}
140147
141148// Constants for env variable names so that we don't typo them.
You can’t perform that action at this time.
0 commit comments