Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b6e4471

Browse filesBrowse files
authored
Merge pull request #4475 from discord9/pr_no_ctrl_c
feat: allow specifying an implementation flag so as to not set SIGINT handler
2 parents e1ab8a9 + 763eaed commit b6e4471
Copy full SHA for b6e4471

File tree

Expand file treeCollapse file tree

3 files changed

+10
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+10
-1
lines changed

‎src/settings.rs

Copy file name to clipboardExpand all lines: src/settings.rs
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ fn settings_from(matches: &ArgMatches) -> (Settings, RunMode) {
245245
if name == "warn_default_encoding" {
246246
warn_default_encoding = true
247247
}
248+
if name == "no_sig_int" {
249+
settings.no_sig_int = true;
250+
}
248251
let value = parts.next().map(ToOwned::to_owned);
249252
(name, value)
250253
}));

‎vm/src/stdlib/signal.rs

Copy file name to clipboardExpand all lines: vm/src/stdlib/signal.rs
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ pub(crate) mod _signal {
103103
.clone()
104104
.get_attr("default_int_handler", vm)
105105
.expect("_signal does not have this attr?");
106-
signal(libc::SIGINT, int_handler, vm).expect("Failed to set sigint handler");
106+
if !vm.state.settings.no_sig_int {
107+
signal(libc::SIGINT, int_handler, vm).expect("Failed to set sigint handler");
108+
}
107109
}
108110

109111
#[pyfunction]

‎vm/src/vm/setting.rs

Copy file name to clipboardExpand all lines: vm/src/vm/setting.rs
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ pub struct Settings {
1616
/// -O optimization switch counter
1717
pub optimize: u8,
1818

19+
/// Not set SIGINT handler(i.e. for embedded mode)
20+
pub no_sig_int: bool,
21+
1922
/// -s
2023
pub no_user_site: bool,
2124

@@ -85,6 +88,7 @@ impl Default for Settings {
8588
inspect: false,
8689
interactive: false,
8790
optimize: 0,
91+
no_sig_int: false,
8892
no_user_site: false,
8993
no_site: false,
9094
ignore_environment: false,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.