Class: BitGirder::Io::UnixProcessBuilder

Inherits:
BitGirderClass
  • Object
show all
Defined in:
lib/bitgirder/io.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ UnixProcessBuilder

Returns a new instance of UnixProcessBuilder.



921
922
923
# File 'lib/bitgirder/io.rb', line 921

def initialize( opts )
    super( opts )
end

Instance Method Details

#execObject



971
972
973
974
975
# File 'lib/bitgirder/io.rb', line 971

def exec

    debug_call( :call_type => "exec" )
    Kernel.exec( *get_call_argv )
end

#popen(mode, &blk) ⇒ Object



999
1000
1001
1002
1003
1004
1005
1006
1007
1008
# File 'lib/bitgirder/io.rb', line 999

def popen( mode, &blk )
    
    debug_call( :call_type => "popen" )

    if RUBY_VERSION >= "1.9"
        IO.popen( get_call_argv, mode, &blk )
    else
        IO.popen( get_call_argv18.join( " " ), mode, &blk )
    end
end

#spawnObject



964
965
966
967
968
# File 'lib/bitgirder/io.rb', line 964

def spawn

    debug_call( :call_type => "spawn" )
    Process.spawn( *get_call_argv )
end

#system(opts = {}) ⇒ Object



978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
# File 'lib/bitgirder/io.rb', line 978

def system( opts = {} )
 
    debug_call( :call_type => "system" )
    
    proc_res_raise = lambda {
        raise "Command exited with status #{$?.exitstatus}"
    }

    if RUBY_VERSION >= "1.9"
        proc_res_raise.call unless Kernel.system( *get_call_argv )
    else
        if pid = Kernel.fork
            Process.wait( pid )
            proc_res_raise.call unless $?.success?
        else
            Kernel.exec( *get_call_argv18 )
        end
    end
end