Skip to content

Commit

Permalink
Hotfix to allow Ctrl+C in python scipts (#3285)
Browse files Browse the repository at this point in the history
* Ignore _skbuild dirs

* Fixed `Context::use_default_signal_handler(bool)` not having any effect

* formatting
  • Loading branch information
Klaim authored May 3, 2024
1 parent dcd777f commit 69ef891
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
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

0 comments on commit 69ef891

Please sign in to comment.