mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-01 14:11:15 +02:00
CHROMIUM: flashrom_tester: Drop nix dependency
We can just use the libc functions directly. This is exactly what nix does anyway. BUG=none TEST=unit tests BRANCH=none Original-Change-Id: I45c02f0c71d164bd8f504fe2b8d3acd54e0d5704 Original-Signed-off-by: Chirantan Ekbote <chirantan@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/+/2560393 Original-Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Original-Reviewed-by: Allen Webb <allenwebb@google.com> Original-Commit-Queue: Allen Webb <allenwebb@google.com> (cherry picked from commit 1ba7dbe83e01d270b6d8d597a079ea3bfeb2117e) Change-Id: Iea61c65efb04da9cd0bc0bd85a34fc10912ea87b Reviewed-on: https://review.coreboot.org/c/flashrom/+/52889 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
This commit is contained in:

committed by
Edward O'Callaghan

parent
32b8bab08c
commit
e7155dda0a
@ -18,8 +18,8 @@ built = { version = "0.3", default-features = false, features = ["serialized_tim
|
|||||||
chrono = { version = "0.4", optional = true }
|
chrono = { version = "0.4", optional = true }
|
||||||
clap = { version = "2.33", default-features = false, optional = true }
|
clap = { version = "2.33", default-features = false, optional = true }
|
||||||
flashrom = { path = "flashrom/" }
|
flashrom = { path = "flashrom/" }
|
||||||
|
libc = "0.2"
|
||||||
log = { version = "0.4", features = ["std"] }
|
log = { version = "0.4", features = ["std"] }
|
||||||
nix = "0.14.1"
|
|
||||||
rand = "0.6.4"
|
rand = "0.6.4"
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
sys-info = "0.5.7"
|
sys-info = "0.5.7"
|
||||||
|
@ -152,12 +152,11 @@ fn main() {
|
|||||||
/// Once a signal is trapped, the default behavior is restored (terminating
|
/// Once a signal is trapped, the default behavior is restored (terminating
|
||||||
/// the process) for future signals.
|
/// the process) for future signals.
|
||||||
fn handle_sigint() -> &'static AtomicBool {
|
fn handle_sigint() -> &'static AtomicBool {
|
||||||
use nix::libc::c_int;
|
use libc::c_int;
|
||||||
use nix::sys::signal::{self, SigHandler, Signal};
|
|
||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
|
|
||||||
unsafe {
|
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);
|
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).
|
test, or press ^C again to exit immediately (possibly bricking your machine).
|
||||||
";
|
";
|
||||||
|
|
||||||
// Use raw write() because signal-safety is a very hard problem
|
// Use raw write() because signal-safety is a very hard problem. Safe because this doesn't
|
||||||
let _ = nix::unistd::write(STDERR_FILENO, MESSAGE);
|
// modify any memory.
|
||||||
|
let _ = unsafe {
|
||||||
|
libc::write(
|
||||||
|
STDERR_FILENO,
|
||||||
|
MESSAGE.as_ptr() as *const libc::c_void,
|
||||||
|
MESSAGE.len() as libc::size_t,
|
||||||
|
)
|
||||||
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
let _ = signal::signal(Signal::SIGINT, SigHandler::SigDfl);
|
let _ = libc::signal(libc::SIGINT, libc::SIG_DFL);
|
||||||
}
|
}
|
||||||
TERMINATE_FLAG.store(true, Ordering::Release);
|
TERMINATE_FLAG.store(true, Ordering::Release);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user