summaryrefslogtreecommitdiff
path: root/Userland/Shell/Shell.cpp
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2021-01-20 00:29:40 +0330
committerAndreas Kling <kling@serenityos.org>2021-01-23 08:28:58 +0100
commitbe94a4ffa6685307b3818210ac2033ded943559d (patch)
tree38a2948d61cdafa1e2db46c5abc3bcaa4bf0682a /Userland/Shell/Shell.cpp
parent2bd77bc93bece47b791a8448db0f6b70003b7831 (diff)
downloadserenity-be94a4ffa6685307b3818210ac2033ded943559d.zip
Shell: Block on the existing event loop instead of pushing a new one
This patch makes `Shell::block_on_job()` pump the event loop while the job it's waiting for hasn't finished. As this no longer pushes new event loops, it has the effect of flattening the stack as well. Fixes #4976.
Diffstat (limited to 'Userland/Shell/Shell.cpp')
-rw-r--r--Userland/Shell/Shell.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp
index ca51af64c8..5d7006a614 100644
--- a/Userland/Shell/Shell.cpp
+++ b/Userland/Shell/Shell.cpp
@@ -1079,17 +1079,18 @@ void Shell::block_on_job(RefPtr<Job> job)
}
} };
- Core::EventLoop loop;
+ bool job_exited { false };
job->on_exit = [&, old_exit = move(job->on_exit)](auto job) {
if (old_exit)
old_exit(job);
- loop.quit(0);
+ job_exited = true;
};
if (job->exited())
return;
- loop.exec();
+ while (!job_exited)
+ Core::EventLoop::current().pump();
// If the job is part of a pipeline, wait for the rest of the members too.
if (auto command = job->command_ptr())