Skip to content

Commit daa9f11

Browse files
committed
feat: allow not set SIGINT handler
1 parent c0ab8e8 commit daa9f11

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

vm/src/stdlib/signal.rs

Lines 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

Lines 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)