Module: Session::Spawn
- Defined in:
- lib/session.rb,
lib/session-2.4.0.rb
Overview
class IDL
Class Method Summary collapse
Class Method Details
.spawn(command) ⇒ Object
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 |
# File 'lib/session.rb', line 703 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
–}}}
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 |
# File 'lib/session.rb', line 719 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 |