mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-23 08:31:16 -03:00
Prevent certain 100% CPU loops
We weren't correctly updating the internal exit generation value. This meant that if one internal process exits, every other internal process that has not exited will continually check, leading to 100% CPU usage. I think this mainly affects concurrent mode, but it may be reproducible if you have a command which refuses to consume its input.
This commit is contained in:
11
src/proc.cpp
11
src/proc.cpp
@@ -393,7 +393,7 @@ static void process_mark_finished_children(parser_t &parser, bool block_ok) {
|
||||
for (const auto &proc : j->processes) {
|
||||
if (!j->can_reap(proc)) continue;
|
||||
|
||||
if (proc->pid) {
|
||||
if (proc->pid > 0) {
|
||||
// Reaps with a pid.
|
||||
reapgens.set_min_from(topic_t::sigchld, proc->gens_);
|
||||
reapgens.set_min_from(topic_t::sighupint, proc->gens_);
|
||||
@@ -421,7 +421,7 @@ static void process_mark_finished_children(parser_t &parser, bool block_ok) {
|
||||
// Does this proc have a pid that is reapable?
|
||||
if (proc->pid <= 0 || !j->can_reap(proc)) continue;
|
||||
|
||||
// Update the signal hup/int gen.
|
||||
// Always update the signal hup/int gen.
|
||||
proc->gens_.sighupint = reapgens.sighupint;
|
||||
|
||||
// Nothing to do if we did not get a new sigchld.
|
||||
@@ -461,6 +461,13 @@ static void process_mark_finished_children(parser_t &parser, bool block_ok) {
|
||||
// Does this proc have an internal process that is reapable?
|
||||
if (!proc->internal_proc_ || !j->can_reap(proc)) continue;
|
||||
|
||||
// Always update the signal hup/int gen.
|
||||
proc->gens_.sighupint = reapgens.sighupint;
|
||||
|
||||
// Nothing to do if we did not get a new internal exit.
|
||||
if (proc->gens_.internal_exit == reapgens.internal_exit) continue;
|
||||
proc->gens_.internal_exit = reapgens.internal_exit;
|
||||
|
||||
// Has the process exited?
|
||||
if (!proc->internal_proc_->exited()) continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user