diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-09-07 22:45:31 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-09-09 20:35:21 +0200 |
commit | 54b453be578e7701ca842301e73ffb6b334e54f6 (patch) | |
tree | 177a404b5e71101f518d6db0d84215ee5db69a36 /Shell/main.cpp | |
parent | c3dbe770243ecc245a5df02e0a1e2cb367d72c31 (diff) | |
download | serenity-54b453be578e7701ca842301e73ffb6b334e54f6.zip |
Shell: Fix event loop processing and backgrounding in subshells
Diffstat (limited to 'Shell/main.cpp')
-rw-r--r-- | Shell/main.cpp | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/Shell/main.cpp b/Shell/main.cpp index 4786c088bd..83877ccfad 100644 --- a/Shell/main.cpp +++ b/Shell/main.cpp @@ -88,28 +88,8 @@ SavedFileDescriptors::~SavedFileDescriptors() } } -int main(int argc, char** argv) +void Shell::setup_signals() { - Core::EventLoop loop; - - Core::EventLoop::register_signal(SIGINT, [](int) { - s_shell->kill_job(s_shell->current_job(), SIGINT); - }); - - Core::EventLoop::register_signal(SIGWINCH, [](int) { - s_shell->kill_job(s_shell->current_job(), SIGWINCH); - }); - - Core::EventLoop::register_signal(SIGTTIN, [](int) {}); - Core::EventLoop::register_signal(SIGTTOU, [](int) {}); - - Core::EventLoop::register_signal(SIGHUP, [](int) { - for (auto& it : s_shell->jobs) - s_shell->kill_job(it.value.ptr(), SIGHUP); - - s_shell->save_history(); - }); - Core::EventLoop::register_signal(SIGCHLD, [](int) { auto& jobs = s_shell->jobs; Vector<u64> disowned_jobs; @@ -159,6 +139,31 @@ int main(int argc, char** argv) job->unblock(); } }); +} + +int main(int argc, char** argv) +{ + Core::EventLoop loop; + + Core::EventLoop::register_signal(SIGINT, [](int) { + s_shell->kill_job(s_shell->current_job(), SIGINT); + }); + + Core::EventLoop::register_signal(SIGWINCH, [](int) { + s_shell->kill_job(s_shell->current_job(), SIGWINCH); + }); + + Core::EventLoop::register_signal(SIGTTIN, [](int) {}); + Core::EventLoop::register_signal(SIGTTOU, [](int) {}); + + Core::EventLoop::register_signal(SIGHUP, [](int) { + for (auto& it : s_shell->jobs) + s_shell->kill_job(it.value.ptr(), SIGHUP); + + s_shell->save_history(); + }); + + s_shell->setup_signals(); #ifndef __serenity__ sigset_t blocked; @@ -168,7 +173,7 @@ int main(int argc, char** argv) pthread_sigmask(SIG_BLOCK, &blocked, NULL); #endif #ifdef __serenity__ - if (pledge("stdio rpath wpath cpath proc exec tty accept sigaction", nullptr) < 0) { + if (pledge("stdio rpath wpath cpath proc exec tty accept sigaction unix fattr", nullptr) < 0) { perror("pledge"); return 1; } |