mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 13:44:57 +00:00
Shell: Wait for the rest of the members of a pipeline when one exits
Assuming we were blocking on one to begin with.
This commit is contained in:
parent
c92865bd05
commit
6e2a383f25
2 changed files with 16 additions and 0 deletions
|
@ -950,6 +950,17 @@ void Shell::restore_ios()
|
|||
tcsetpgrp(STDIN_FILENO, m_pid);
|
||||
}
|
||||
|
||||
void Shell::block_on_pipeline(RefPtr<AST::Pipeline> pipeline)
|
||||
{
|
||||
if (!pipeline)
|
||||
return;
|
||||
|
||||
for (auto& it : jobs) {
|
||||
if (auto cmd = it.value->command_ptr(); cmd->pipeline == pipeline && cmd->is_pipe_source)
|
||||
block_on_job(it.value);
|
||||
}
|
||||
}
|
||||
|
||||
void Shell::block_on_job(RefPtr<Job> job)
|
||||
{
|
||||
TemporaryChange<const Job*> current_job { m_current_job, job.ptr() };
|
||||
|
@ -977,6 +988,10 @@ void Shell::block_on_job(RefPtr<Job> job)
|
|||
return;
|
||||
|
||||
loop.exec();
|
||||
|
||||
// If the job is part of a pipeline, wait for the rest of the members too.
|
||||
if (auto command = job->command_ptr())
|
||||
block_on_pipeline(command->pipeline);
|
||||
}
|
||||
|
||||
String Shell::get_history_path()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue