mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Shell: Do not attempt to yank the TTY from background processes
They don't own the TTY anyway!
This commit is contained in:
parent
217eca3d3f
commit
cf18bff72a
Notes:
sideshowbarker
2024-07-19 03:24:53 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/cf18bff72ac Pull-request: https://github.com/SerenityOS/serenity/pull/3165 Issue: https://github.com/SerenityOS/serenity/issues/3160 Reviewed-by: https://github.com/BenWiederhake Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/bugaevc
2 changed files with 15 additions and 8 deletions
|
@ -76,6 +76,7 @@ public:
|
|||
bool should_be_disowned() const { return m_should_be_disowned; }
|
||||
void disown() { m_should_be_disowned = true; }
|
||||
bool is_running_in_background() const { return m_running_in_background; }
|
||||
bool should_announce_exit() const { return m_should_announce_exit; }
|
||||
bool is_suspended() const { return m_is_suspended; }
|
||||
void unblock() const
|
||||
{
|
||||
|
@ -113,6 +114,8 @@ public:
|
|||
m_running_in_background = running_in_background;
|
||||
}
|
||||
|
||||
void set_should_announce_exit(bool value) { m_should_announce_exit = value; }
|
||||
|
||||
void deactivate() const { m_active = false; }
|
||||
|
||||
enum class PrintStatusMode {
|
||||
|
@ -143,6 +146,7 @@ private:
|
|||
String m_cmd;
|
||||
bool m_exited { false };
|
||||
bool m_running_in_background { false };
|
||||
bool m_should_announce_exit { false };
|
||||
int m_exit_code { -1 };
|
||||
int m_term_sig { -1 };
|
||||
Core::ElapsedTimer m_command_timer;
|
||||
|
|
|
@ -626,7 +626,7 @@ RefPtr<Job> Shell::run_command(const AST::Command& command)
|
|||
job->on_exit = [](auto job) {
|
||||
if (!job->exited())
|
||||
return;
|
||||
if (job->is_running_in_background())
|
||||
if (job->is_running_in_background() && job->should_announce_exit())
|
||||
fprintf(stderr, "Shell: Job %" PRIu64 "(%s) exited\n", job->job_id(), job->cmd().characters());
|
||||
job->disown();
|
||||
};
|
||||
|
@ -670,10 +670,10 @@ NonnullRefPtrVector<Job> Shell::run_commands(Vector<AST::Command>& commands)
|
|||
jobs_to_wait_for.append(*job);
|
||||
} else {
|
||||
if (command.is_pipe_source) {
|
||||
job->set_running_in_background(true);
|
||||
jobs_to_wait_for.append(*job);
|
||||
} else if (command.should_notify_if_in_background) {
|
||||
job->set_running_in_background(true);
|
||||
restore_ios();
|
||||
job->set_should_announce_exit(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -710,23 +710,26 @@ void Shell::block_on_job(RefPtr<Job> job)
|
|||
if (!job)
|
||||
return;
|
||||
|
||||
ScopeGuard io_restorer { [&]() {
|
||||
if (job->exited() && !job->is_running_in_background()) {
|
||||
restore_ios();
|
||||
}
|
||||
} };
|
||||
|
||||
Core::EventLoop loop;
|
||||
job->on_exit = [&, old_exit = move(job->on_exit)](auto job) {
|
||||
if (old_exit)
|
||||
old_exit(job);
|
||||
loop.quit(0);
|
||||
};
|
||||
if (job->exited()) {
|
||||
restore_ios();
|
||||
|
||||
if (job->exited())
|
||||
return;
|
||||
}
|
||||
|
||||
loop.exec();
|
||||
|
||||
if (job->is_suspended())
|
||||
job->print_status(Job::PrintStatusMode::Basic);
|
||||
|
||||
restore_ios();
|
||||
}
|
||||
|
||||
String Shell::get_history_path()
|
||||
|
|
Loading…
Reference in a new issue