Skip to content

Commit 0b22caa

Browse files
author
Antonino Calderone
committed
Add enable/disable signal handler notifications
1 parent 5e2fe62 commit 0b22caa

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

nu_interpreter.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,9 @@ interpreter_t::exec_res_t interpreter_t::exec_command(const std::string& cmd)
12891289
if (load(f))
12901290
{
12911291
set_ignore_break_event(true);
1292-
run(0);
1292+
signal_mgr_t::instance().disable_notifications();
1293+
bool res = run(0);
1294+
exit(res ? 0 : 1);
12931295
return exec_res_t::CMD_EXEC;
12941296
}
12951297

nu_signal_handling.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ bool signal_mgr_t::dispatch(signal_handler_t::event_t ev)
9898
// dependences
9999
bool _ev_dispatcher(signal_handler_t::event_t ev)
100100
{
101-
return signal_mgr_t::instance().dispatch(ev);
101+
if (! signal_mgr_t::instance()._disable_notifications)
102+
return signal_mgr_t::instance().dispatch(ev);
103+
104+
return true;
102105
}
103106

104107

nu_signal_handling.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ class signal_mgr_t
9393
i->second.erase(handle);
9494
}
9595

96+
97+
void disable_notifications() throw()
98+
{
99+
_disable_notifications = true;
100+
}
101+
102+
103+
void enable_notifications() throw()
104+
{
105+
_disable_notifications = false;
106+
}
107+
96108

97109
protected:
98110
using hlist_t = std::set < signal_handler_t::handle_t > ;
@@ -102,6 +114,8 @@ class signal_mgr_t
102114
bool dispatch(signal_handler_t::event_t ev);
103115

104116
friend bool _ev_dispatcher(signal_handler_t::event_t ev);
117+
118+
bool _disable_notifications = false;
105119
};
106120

107121

0 commit comments

Comments
 (0)