Programming & Scripting ¶
How to create Ruby subprocess
- Do I want to return to my Ruby script at all?
- No! Use Kernel exec:
- Yes! Is it OK to block until the process completes?
- Yes! Do I need the program’s output to be returned?
- No! Do I need to interact with the output?
- No! Use Kernel fork:
fork() - seperate child process (daemonize).
- Yes! Do I want stderr?
- No! Use IO popen:
IO.popen() (or use
2>&1 if you want both stderr and stdout).
- Yes! Do I want stderr in a separate stream?
Bitmand - a self-proclaimed Internet Enthusiast!