Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix to allow Ctrl+C in python scipts #3285

Merged
merged 3 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,4 @@ __cache__/
installed.json
tmp/
test_7.json.state
_skbuild/
1 change: 1 addition & 0 deletions libmamba/include/mamba/core/thread_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace mamba
#endif

void set_default_signal_handler();
void restore_system_signal_handler();
bool is_sig_interrupted() noexcept;
void set_sig_interrupted() noexcept;

Expand Down
8 changes: 8 additions & 0 deletions libmamba/src/core/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ namespace mamba
void Context::use_default_signal_handler(bool val)
{
use_default_signal_handler_val = val;
if (use_default_signal_handler_val)
{
set_default_signal_handler();
}
else
{
restore_system_signal_handler();
}
}

void Context::enable_logging_and_signal_handling(Context& context)
Expand Down
4 changes: 4 additions & 0 deletions libmamba/src/core/thread_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ namespace mamba
std::signal(SIGINT, [](int /*signum*/) { set_sig_interrupted(); });
}
#endif
void restore_system_signal_handler()
{
std::signal(SIGINT, SIG_DFL);
}

bool is_sig_interrupted() noexcept
{
Expand Down
Loading