This PR fixes a subtle iterate-remove bug when checking subprocesses. Previously, subprocesses were deleted by index, which would shift the remaining processes and their index to go out of sync. This caused the wrong process to be deleted if more than one died in a cycle. See #2372.
Instead of being deleted-appended, process are now replaced inplace to ensure positions and thus iteration is stable. This also makes copying the process list superfluous, so I removed this where appropriate.
Checklist
[x] I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
[ ] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
Summary
This PR fixes a subtle iterate-remove bug when checking subprocesses. Previously, subprocesses were deleted by index, which would shift the remaining processes and their index to go out of sync. This caused the wrong process to be deleted if more than one died in a cycle. See #2372.
Instead of being deleted-appended, process are now replaced inplace to ensure positions and thus iteration is stable. This also makes copying the process list superfluous, so I removed this where appropriate.
Checklist