Bitcoin Core functional tests for the echoipc RPC method were occasionally timing out, see https://github.com/bitcoin/bitcoin/issues/34187. A helpful LLM quickly figured out it was due to doing unsafe things after fork().
https://pubs.opengroup.org/onlinepubs/009695399/functions/fork.html
Fix it by having SpawnProcess evaluate fd_to_args and build argv in the parent before fork().
SpawnProcess now avoids ExecProcess. I intentionally did not fix the latter, not just to reduce churn, but also because it’s now only used by mpgen and it doesn’t seem worth losing the debug errors it (unsafely) throws.
The last commit adds a test which reproduces the issue.