Class: Flaky::Cmd
- Inherits:
-
Object
- Object
- Flaky::Cmd
- Defined in:
- lib/flaky/cmd.rb
Instance Attribute Summary collapse
-
#err ⇒ Object
readonly
Returns the value of attribute err.
-
#in ⇒ Object
readonly
Returns the value of attribute in.
-
#out ⇒ Object
readonly
Returns the value of attribute out.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Method Summary collapse
-
#initialize(cmd) ⇒ Cmd
constructor
A new instance of Cmd.
- #stop ⇒ Object
Constructor Details
#initialize(cmd) ⇒ Cmd
Returns a new instance of Cmd.
5 6 7 8 9 |
# File 'lib/flaky/cmd.rb', line 5 def initialize cmd # redirect err to child's out @pid, @in, @out, @err = POSIX::Spawn::popen4 cmd, { :err => [:child, :out] } @in.close end |
Instance Attribute Details
#err ⇒ Object (readonly)
Returns the value of attribute err.
3 4 5 |
# File 'lib/flaky/cmd.rb', line 3 def err @err end |
#in ⇒ Object (readonly)
Returns the value of attribute in.
3 4 5 |
# File 'lib/flaky/cmd.rb', line 3 def in @in end |
#out ⇒ Object (readonly)
Returns the value of attribute out.
3 4 5 |
# File 'lib/flaky/cmd.rb', line 3 def out @out end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
3 4 5 |
# File 'lib/flaky/cmd.rb', line 3 def pid @pid end |
Instance Method Details
#stop ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/flaky/cmd.rb', line 11 def stop [@in, @out, @err].each { |io| io.close unless io.nil? || io.closed? } begin Process.kill 'KILL', @pid Process.waitpid @pid rescue # no such process end end |