In C / C++ you read stdout from a sub process via dup2( ..., STDERR_FILENO)[1]. I don't really understand what dup2 does; can I do it twice for two sub processes that are running at the same time? I'm seeing an issue with my existing implementation where one them isn't able to finish reading STDERR and I'm wondering if that's an implementation bug or whether it's just not possible.
Edit: They're started by separate threads. Starting and stopping may interleave in any way.
[1] e.g. like Linux 3.0: Executing child process with piped stdin/stdout