Module: Session::Spawn
- Defined in:
- lib/session.rb
Overview
class IDL
Class Method Summary collapse
Class Method Details
.spawn(command) ⇒ Object
623 624 625 626 627 628 629 630 631 632 633 634 635 636 |
# File 'lib/session.rb', line 623 def spawn command ipath = tmpfifo opath = tmpfifo epath = tmpfifo cmd = "#{ command } < #{ ipath } 1> #{ opath } 2> #{ epath } &" system cmd i = open ipath, 'w' o = open opath, 'r' e = open epath, 'r' [i,o,e] end |
.tmpfifo ⇒ Object
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 |
# File 'lib/session.rb', line 637 def tmpfifo path = nil 42.times do |i| tpath = File::join(Dir::tmpdir, "#{ $$ }.#{ rand }.#{ i }") v = $VERBOSE begin $VERBOSE = nil system "mkfifo #{ tpath }" ensure $VERBOSE = v end next unless $? == 0 path = tpath at_exit{ File::unlink(path) rescue STDERR.puts("rm <#{ path }> failed") } break end raise "could not generate tmpfifo" unless path path end |