Shell: Make the ENSURE_WAITID_ONCE requirements a bit less strict
waitid() *may* be called many times if a job does not exit, so only assert this fact when the job has in fact exited. Also allows Background nodes to contain non-execute nodes.
This commit is contained in:
parent
8de70e8ce7
commit
9ad858bcbf
Notes:
sideshowbarker
2024-07-19 01:42:40 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/9ad858bcbf7 Pull-request: https://github.com/SerenityOS/serenity/pull/3852 Reviewed-by: https://github.com/asynts
2 changed files with 11 additions and 3 deletions
|
@ -228,10 +228,9 @@ RefPtr<AST::Node> Parser::parse_sequence()
|
|||
return first;
|
||||
}
|
||||
case '&': {
|
||||
auto execute_pipe_seq = first->would_execute() ? first.release_nonnull() : static_cast<NonnullRefPtr<AST::Node>>(create<AST::Execute>(first.release_nonnull()));
|
||||
consume();
|
||||
auto pos_after_seps = save_offset();
|
||||
auto bg = create<AST::Background>(execute_pipe_seq); // Execute Background
|
||||
auto bg = create<AST::Background>(first.release_nonnull()); // Execute Background
|
||||
if (auto rest = parse_sequence())
|
||||
return create<AST::Sequence>(
|
||||
move(bg),
|
||||
|
|
|
@ -1443,7 +1443,16 @@ void Shell::notify_child_event()
|
|||
}
|
||||
found_child = true;
|
||||
#ifdef ENSURE_WAITID_ONCE
|
||||
s_waited_for_pids.set(child_pid);
|
||||
// NOTE: This check is here to find bugs about our assumptions about waitpid(),
|
||||
// it does not hold in general, and it definitely does not hold in the long run.
|
||||
// Reasons that we would call waitpid() more than once:
|
||||
// - PID reuse/wraparound: This will simply fail the assertion, ignored here.
|
||||
// - Non-terminating unblocks:
|
||||
// - Suspension: (e.g. via ^Z)
|
||||
// - ?
|
||||
// - ?
|
||||
if (job.exited())
|
||||
s_waited_for_pids.set(child_pid);
|
||||
#endif
|
||||
}
|
||||
if (job.should_be_disowned())
|
||||
|
|
Loading…
Add table
Reference in a new issue