Skip to content

Commit

Permalink
[MegaLinter] Apply linters fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 25, 2024
1 parent 9ec1679 commit 19b7d6e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/ui/ctrlc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ use console::Term;
use signal_hook::consts::SIGINT;
use signal_hook::iterator::{Handle, Signals};
use std::process::exit;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::{AtomicBool, Ordering};
use std::thread;

#[derive(Debug)]
pub(crate) struct HandleGuard(Handle);
pub struct HandleGuard(Handle);

/// ensures cursor is displayed on ctrl-c
pub fn handle_ctrlc() -> eyre::Result<Option<HandleGuard>> {
static HANDLED: AtomicBool = AtomicBool::new(false);
let handled = HANDLED.swap(true, std::sync::atomic::Ordering::Relaxed);
let handled = HANDLED.swap(true, Ordering::Relaxed);
if handled {
return Ok(None);
}
Expand All @@ -24,7 +24,7 @@ pub fn handle_ctrlc() -> eyre::Result<Option<HandleGuard>> {
debug!("Ctrl-C pressed, exiting...");
exit(1);
}
HANDLED.store(false, std::sync::atomic::Ordering::Relaxed);
HANDLED.store(false, Ordering::Relaxed);
});
Ok(Some(handle))
}
Expand Down
16 changes: 8 additions & 8 deletions test/fixtures/signal-test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
let i = 3;
let i = 3

process.on('SIGINT', function() {
process.on('SIGINT', function () {
if (i > 0) {
console.log(`Got SIGINT. Press Control-D to exit. ${i} times left`);
i--;
console.log(`Got SIGINT. Press Control-D to exit. ${i} times left`)
i--
} else {
process.exit();
process.exit()
}
});
})

// wait for 60 seconds
setTimeout(function() {}, 60000);
console.log('Running. Press Control-C to test.');
setTimeout(function () {}, 60000)
console.log('Running. Press Control-C to test.')

0 comments on commit 19b7d6e

Please sign in to comment.