diff options
Diffstat (limited to 'util/flashrom_tester/src')
| -rw-r--r-- | util/flashrom_tester/src/main.rs | 18 | 
1 files changed, 12 insertions, 6 deletions
diff --git a/util/flashrom_tester/src/main.rs b/util/flashrom_tester/src/main.rs index e589ee1e..80484d20 100644 --- a/util/flashrom_tester/src/main.rs +++ b/util/flashrom_tester/src/main.rs @@ -152,12 +152,11 @@ fn main() {  /// Once a signal is trapped, the default behavior is restored (terminating  /// the process) for future signals.  fn handle_sigint() -> &'static AtomicBool { -    use nix::libc::c_int; -    use nix::sys::signal::{self, SigHandler, Signal}; +    use libc::c_int;      use std::sync::atomic::Ordering;      unsafe { -        let _ = signal::signal(Signal::SIGINT, SigHandler::Handler(sigint_handler)); +        let _ = libc::signal(libc::SIGINT, sigint_handler as libc::sighandler_t);      }      static TERMINATE_FLAG: AtomicBool = AtomicBool::new(false); @@ -169,10 +168,17 @@ rendering your machine unbootable. Testing will end on completion of the current  test, or press ^C again to exit immediately (possibly bricking your machine).  "; -        // Use raw write() because signal-safety is a very hard problem -        let _ = nix::unistd::write(STDERR_FILENO, MESSAGE); +        // Use raw write() because signal-safety is a very hard problem. Safe because this doesn't +        // modify any memory. +        let _ = unsafe { +            libc::write( +                STDERR_FILENO, +                MESSAGE.as_ptr() as *const libc::c_void, +                MESSAGE.len() as libc::size_t, +            ) +        };          unsafe { -            let _ = signal::signal(Signal::SIGINT, SigHandler::SigDfl); +            let _ = libc::signal(libc::SIGINT, libc::SIG_DFL);          }          TERMINATE_FLAG.store(true, Ordering::Release);      }  | 
