-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
quickenv now warns to run 'shim' after 'pip install'
See #1
- Loading branch information
Showing
4 changed files
with
206 additions
and
42 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use anyhow::Error; | ||
use std::process::exit; | ||
|
||
use std::sync::atomic::{AtomicBool, Ordering}; | ||
|
||
static SHIM_HAS_CONTROL: AtomicBool = AtomicBool::new(false); | ||
const INTERRUPTED_EXIT_CODE: i32 = 130; | ||
|
||
pub fn pass_control_to_shim() { | ||
// the control-passing behavior was blatantly stolen from volta. | ||
// https://github.com/volta-cli/volta/blob/5b5c94285500b1023f773215a7ef85aaeeeaffbd/crates/volta-core/src/signal.rs | ||
SHIM_HAS_CONTROL.store(true, Ordering::SeqCst); | ||
} | ||
|
||
pub fn set_ctrlc_handler() -> Result<(), Error> { | ||
ctrlc::set_handler(move || { | ||
if !SHIM_HAS_CONTROL.load(Ordering::SeqCst) { | ||
// necessary to work around https://github.com/mitsuhiko/dialoguer/issues/188 | ||
let term = console::Term::stdout(); | ||
term.show_cursor().unwrap(); | ||
exit(INTERRUPTED_EXIT_CODE); | ||
} | ||
})?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters