Module: NzbGetPP::Shellout
- Included in:
- PostProcessor
- Defined in:
- lib/nzbgetpp/shellout.rb
Instance Method Summary collapse
-
#shellout(cmd) ⇒ Object
FIXME: probably want to implement timeouts here..
Instance Method Details
#shellout(cmd) ⇒ Object
FIXME: probably want to implement timeouts here..
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/nzbgetpp/shellout.rb', line 4 def shellout(cmd) stdout_rd, stdout_wr = IO.pipe stderr_rd, stderr_wr = IO.pipe child_pid, child_status = nil child_pid = Kernel.fork if child_pid stdout_wr.close stderr_wr.close return [child_pid, stdout_rd, stderr_rd] else Process.setsid STDIN.close STDOUT.reopen(stdout_wr) STDERR.reopen(stderr_wr) 3.upto(256) { |fd| IO.new(fd).close rescue nil } Kernel.exec(cmd) # Never reached. Kernel.exit! end end |