In Ruby, is it possible to prevent the standard input of a spawned child process from being attached to the terminal without having to capture the STDOUT or STDERR of that same process?
Backticks and x-strings (
`...`,%x{...}) don't work because they capture STDIN.Kernel#systemdoesn't work because it leaves STDIN attached to the terminal (which intercepts signals like^Cand prevents them from reaching my program, which is what I'm trying to avoid).Open3doesn't work because its methods capture eitherSTDOUTor bothSTDOUTandSTDERR.
So what should I use?
If you’re on a platform that supports it, you could do this with
pipe,forkandexec: