The answer to this question is in the documentation. Do you write code for your own use in a controlled environment? Or widely used by third parties? Ruby is written for widespread use by third parties, so their recommendation is not to do something that might fail on "some operating systems." Perhaps the Spawn library is designed primarily for use on Linux machines and tested only on a small subset of it, where this tactic works.
If you distribute the code you write to be used by anyone and everyone, I would take the Ruby approach.
If you control the environment in which this code will be executed, I would write two tests:
- A test that spawns a process separates it and then waits for it.
- A test that starts a process and then just waits for it.
Count the failure rate for both, and if they are equal (within the acceptable range), go for it!
source share