mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Merge pull request #4475 from discord9/pr_no_ctrl_c
feat: allow specifying an implementation flag so as to not set SIGINT handler
This commit is contained in:
@@ -245,6 +245,9 @@ fn settings_from(matches: &ArgMatches) -> (Settings, RunMode) {
|
||||
if name == "warn_default_encoding" {
|
||||
warn_default_encoding = true
|
||||
}
|
||||
if name == "no_sig_int" {
|
||||
settings.no_sig_int = true;
|
||||
}
|
||||
let value = parts.next().map(ToOwned::to_owned);
|
||||
(name, value)
|
||||
}));
|
||||
|
||||
@@ -103,7 +103,9 @@ pub(crate) mod _signal {
|
||||
.clone()
|
||||
.get_attr("default_int_handler", vm)
|
||||
.expect("_signal does not have this attr?");
|
||||
signal(libc::SIGINT, int_handler, vm).expect("Failed to set sigint handler");
|
||||
if !vm.state.settings.no_sig_int {
|
||||
signal(libc::SIGINT, int_handler, vm).expect("Failed to set sigint handler");
|
||||
}
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
|
||||
@@ -16,6 +16,9 @@ pub struct Settings {
|
||||
/// -O optimization switch counter
|
||||
pub optimize: u8,
|
||||
|
||||
/// Not set SIGINT handler(i.e. for embedded mode)
|
||||
pub no_sig_int: bool,
|
||||
|
||||
/// -s
|
||||
pub no_user_site: bool,
|
||||
|
||||
@@ -85,6 +88,7 @@ impl Default for Settings {
|
||||
inspect: false,
|
||||
interactive: false,
|
||||
optimize: 0,
|
||||
no_sig_int: false,
|
||||
no_user_site: false,
|
||||
no_site: false,
|
||||
ignore_environment: false,
|
||||
|
||||
Reference in New Issue
Block a user