1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 14:05:08 +00:00

Shell: Handle signals asynchronously

Fixes #2717
This commit is contained in:
Tom 2020-07-06 15:49:11 -06:00 committed by Andreas Kling
parent 6751d03ea7
commit 6dfd503518
3 changed files with 7 additions and 17 deletions

View file

@ -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<u64> 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;