Class: Purple::Run::Child
- Inherits:
-
Object
- Object
- Purple::Run::Child
- Defined in:
- lib/purple/process.rb
Instance Attribute Summary collapse
-
#exit_code ⇒ Object
readonly
Returns the value of attribute exit_code.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(name, dir, cmd, *args) ⇒ Child
constructor
A new instance of Child.
- #start ⇒ Object
Constructor Details
#initialize(name, dir, cmd, *args) ⇒ Child
Returns a new instance of Child.
5 6 7 8 9 10 |
# File 'lib/purple/process.rb', line 5 def initialize name, dir, cmd, *args @out = File.new File.join(dir, name + ".out"), 'w' @err = File.new File.join(dir, name + ".err"), 'w' @cmd, @args = cmd, args @status = @exit_code = nil end |
Instance Attribute Details
#exit_code ⇒ Object (readonly)
Returns the value of attribute exit_code.
11 12 13 |
# File 'lib/purple/process.rb', line 11 def exit_code @exit_code end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
11 12 13 |
# File 'lib/purple/process.rb', line 11 def status @status end |
Instance Method Details
#start ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/purple/process.rb', line 13 def start pid = fork do STDOUT.reopen @out STDERR.reopen @err puts "> #{@cmd} #{@args.join ' '}" exec @cmd, *@args end Thread.new do begin #puts "DEBUG Purple::Process::Child#start: HERE" if $DEBUG @exit_code = Process.waitpid2(pid)[1].exitstatus #puts "DEBUG Purple::Process::Child#start: status=#{@exit_code}" if $DEBUG ensure @status = :done end end #pid end |