To do some simple parallel processing I have two nim programs, where one simply runs a number of the other through osproc's `startProcess`, waits for them to end, and then does some final stuff with the outputs. The child program can be run by itself, with exactly the same parameters as given by the parent without any issues, and always terminates correctly on its own.
I have run into a strange behavior that I simply cannot get my mind around. I have a simple waiting loop that counts the number of ended processes with `p.running()` and then processes the outputs after they have all stopped. Now, coding sloppily on my own I have no idea what caused this, but at one point a problem began where this parent process wouldn't end. After each child process should have ended naturally (because they have a time limit), using either `running` or `peekExitCode` would return `true` or `-1` respectively. This happens seemingly at random, to a random number of child processes each run. So I tried making it end the child processes instead of waiting, and then looked at the output to see where things went wrong. But from the output it is very clear that each of the processes had in fact concluded, especially after I added `assert false` at the very end to make sure. The child processes, which each use a significant amount of cpu while running, each drop to 0% usage after the allotted time as well. Now, just to make this extra strange, I tried to see what happened to exit code for the running processes as I interacted with the outputs, and found that peeking the code after running through a `for line in p.lines()` loop, they are then changed to the expected `0` (or `1` with the assert). So I echoed the lines as I read them, and then echoed the peeked code after each line. The baffling result (to me at least) is that some way through outputting the lines, the peeked code changes. I have no idea where to even look at this point. Am I just misunderstanding something about running processes? Are there extra steps take to "update" the status of them?
