Class: Rubysh::Subprocess
- Inherits:
-
Object
- Object
- Rubysh::Subprocess
- Defined in:
- lib/rubysh/subprocess.rb,
lib/rubysh/subprocess/parallel_io.rb,
lib/rubysh/subprocess/pipe_wrapper.rb,
lib/rubysh/subprocess/pid_aware_parallel_io.rb
Defined Under Namespace
Classes: ParallelIO, PidAwareParallelIO, PipeWrapper
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#command ⇒ Object
Returns the value of attribute command.
-
#directives ⇒ Object
Returns the value of attribute directives.
-
#exec_error ⇒ Object
Returns the value of attribute exec_error.
-
#pid ⇒ Object
Returns the value of attribute pid.
-
#runner ⇒ Object
Returns the value of attribute runner.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(args, blk = nil, directives = [], post_fork = [], runner = nil) ⇒ Subprocess
constructor
TODO: switch directives over to an OrderedHash of some form? Really want to preserve the semantics here.
- #run ⇒ Object
- #to_s ⇒ Object
- #wait(nonblock = false) ⇒ Object
Constructor Details
#initialize(args, blk = nil, directives = [], post_fork = [], runner = nil) ⇒ Subprocess
TODO: switch directives over to an OrderedHash of some form? Really want to preserve the semantics here.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rubysh/subprocess.rb', line 17 def initialize(args, blk=nil, directives=[], post_fork=[], runner=nil) raise ArgumentError.new("Must provide an array (#{args.inspect} provided)") unless args.kind_of?(Array) if args.length > 0 && blk raise ArgumentError.new("Provided both arguments (#{args.inspect}) and a block (#{blk.inspect}). You can only provide one.") elsif args.length == 0 && !blk raise ArgumentError.new("No command specified (#{args.inspect} provided)") end @command = args[0] @args = args[1..-1] @blk = blk @directives = directives @runner = runner Rubysh.assert(@directives.length == 0 || @runner, "Directives provided but no runner is", true) @exec_status = nil @post_fork = post_fork @pid = nil @status = nil @exec_error = nil Rubysh.log.debug("Just created: #{self}") end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
12 13 14 |
# File 'lib/rubysh/subprocess.rb', line 12 def args @args end |
#command ⇒ Object
Returns the value of attribute command.
12 13 14 |
# File 'lib/rubysh/subprocess.rb', line 12 def command @command end |
#directives ⇒ Object
Returns the value of attribute directives.
12 13 14 |
# File 'lib/rubysh/subprocess.rb', line 12 def directives @directives end |
#exec_error ⇒ Object
Returns the value of attribute exec_error.
13 14 15 |
# File 'lib/rubysh/subprocess.rb', line 13 def exec_error @exec_error end |
#pid ⇒ Object
Returns the value of attribute pid.
13 14 15 |
# File 'lib/rubysh/subprocess.rb', line 13 def pid @pid end |
#runner ⇒ Object
Returns the value of attribute runner.
12 13 14 |
# File 'lib/rubysh/subprocess.rb', line 12 def runner @runner end |
#status ⇒ Object
Returns the value of attribute status.
13 14 15 |
# File 'lib/rubysh/subprocess.rb', line 13 def status @status end |
Instance Method Details
#run ⇒ Object
48 49 50 51 |
# File 'lib/rubysh/subprocess.rb', line 48 def run do_run unless @pid @pid end |
#to_s ⇒ Object
44 45 46 |
# File 'lib/rubysh/subprocess.rb', line 44 def to_s "Subprocess: command=#{@command.inspect} blk=#{@blk.inspect} args=#{@args.inspect} directives: #{@directives.inspect}" end |
#wait(nonblock = false) ⇒ Object
53 54 55 56 |
# File 'lib/rubysh/subprocess.rb', line 53 def wait(nonblock=false) do_wait(nonblock) unless @status @status end |