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

Fix issue #4201. #4205

Merged
merged 1 commit into from
Mar 13, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/shogun/lib/Signal.cpp
Expand Up @@ -14,7 +14,7 @@
using namespace shogun;
using namespace rxcpp;

bool CSignal::m_active = false;
bool CSignal::m_active = true;
CSignal::SGSubjectS* CSignal::m_subject = new rxcpp::subjects::subject<int>();

CSignal::SGObservableS* CSignal::m_observable =
Expand All @@ -32,9 +32,9 @@ CSignal::~CSignal()

void CSignal::handler(int signal)
{
/* If the handler is not enabled, then return */
/* If the handler is not enabled exit */
if (!m_active)
return;
exit(-1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure we want exit(-1) ? i mean in this case of a REPL we would exit the REPL itself, or?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user won't enter into REPL loop if m_active is set to false. In such a situation, the handler won't ask the user any inputs, it will just terminate the execution and it won't print any message to the screen either. So I decided to maintain a consisten behaviour between the Shogun's handler and the standard system handler when dealing with a SIGINT: exit and set the exit code != 0.


if (signal == SIGINT)
{
Expand Down
7 changes: 4 additions & 3 deletions src/shogun/lib/Signal.h
Expand Up @@ -71,11 +71,12 @@ namespace shogun
};
#endif

/** Enable signal handler
/** Enable/Disable custon Shogun's signal handler
* @param enable true to enable the handler, false otherwise.
*/
void enable_handler()
void enable_handler(bool enable)
{
m_active = true;
m_active = enable;
}
/**
* Reset handler in case of multiple instantiation
Expand Down
3 changes: 0 additions & 3 deletions tests/unit/lib/Signal_unittest.cc
Expand Up @@ -44,7 +44,6 @@ using namespace rxcpp;
TEST(Signal, return_to_prompt_test)
{
CSignal tmp;
tmp.enable_handler();
int on_next_v = 0;
int on_complete_v = 0;
auto sub = rxcpp::make_subscriber<int>(
Expand All @@ -62,7 +61,6 @@ TEST(Signal, prematurely_stop_computation_test)
{

CSignal tmp;
tmp.enable_handler();
int on_next_v = 0;
int on_complete_v = 0;
auto sub = rxcpp::make_subscriber<int>(
Expand All @@ -80,7 +78,6 @@ TEST(Signal, pause_computation_test)
{

CSignal tmp;
tmp.enable_handler();
int on_next_v = 0;
int on_complete_v = 0;
auto sub = rxcpp::make_subscriber<int>(
Expand Down