Multithreading - does Process.wait's return value ($?) create a race condition?

I would like to use many ruby threads and call Process.wait within them concurrently (on different processes created within each thread). However, given the “return” value of Process.wait is a shared global value ($?) this sounds like I could suffer race condition issues.

Am I right to be concerned? What’s my best way of avoiding this?

I would prefer to have individual threads waiting on single processes if possible, rather than simply launching them in parallel and doing a bulk wait.


Just in case anyone else with the same problem reads this, this problem is solved by using wait2() instead of wait().