diff --git a/Shell/Shell.cpp b/Shell/Shell.cpp index b979808519..09faef91bb 100644 --- a/Shell/Shell.cpp +++ b/Shell/Shell.cpp @@ -516,9 +516,6 @@ void Shell::restore_stdin() void Shell::block_on_job(RefPtr job) { - ScopedValueRollback accepting_signal_rollback(m_is_accepting_signals); - m_is_accepting_signals = false; - if (!job) return; diff --git a/Shell/Shell.h b/Shell/Shell.h index 0d6d1193dc..b122e38b5e 100644 --- a/Shell/Shell.h +++ b/Shell/Shell.h @@ -72,8 +72,6 @@ public: constexpr static auto local_init_file_path = "~/.shellrc"; constexpr static auto global_init_file_path = "/etc/shellrc"; - bool is_accepting_signals() const { return m_is_accepting_signals; } - int run_command(const StringView&); RefPtr run_command(AST::Command&); bool run_file(const String&, bool explicitly_invoked = true); @@ -183,7 +181,6 @@ private: StringBuilder m_complete_line_builder; bool m_should_ignore_jobs_on_next_exit { false }; - bool m_is_accepting_signals { true }; pid_t m_pid { 0 }; HashMap> m_local_variables; diff --git a/Shell/main.cpp b/Shell/main.cpp index 977e9988ad..110238881e 100644 --- a/Shell/main.cpp +++ b/Shell/main.cpp @@ -60,26 +60,22 @@ int main(int argc, char** argv) { Core::EventLoop loop; - signal(SIGINT, [](int) { - if (!s_shell->is_accepting_signals()) - return; + Core::EventLoop::register_signal(SIGINT, [](int) { editor->interrupted(); }); - signal(SIGWINCH, [](int) { + Core::EventLoop::register_signal(SIGWINCH, [](int) { editor->resized(); }); - signal(SIGTTIN, [](int) {}); - signal(SIGTTOU, [](int) {}); + Core::EventLoop::register_signal(SIGTTIN, [](int) {}); + Core::EventLoop::register_signal(SIGTTOU, [](int) {}); - signal(SIGHUP, [](int) { - if (!s_shell->is_accepting_signals()) - return; + Core::EventLoop::register_signal(SIGHUP, [](int) { s_shell->save_history(); }); - signal(SIGCHLD, [](int) { + Core::EventLoop::register_signal(SIGCHLD, [](int) { auto& jobs = s_shell->jobs; Vector disowned_jobs; for (auto& job : jobs) { @@ -116,7 +112,7 @@ int main(int argc, char** argv) }); // Ignore SIGTSTP as the shell should not be suspended with ^Z. - signal(SIGTSTP, [](auto) {}); + Core::EventLoop::register_signal(SIGTSTP, [](auto) {}); #ifndef __serenity__ sigset_t blocked;