Class: MultipleCmd::SubProc
- Inherits:
-
Object
- Object
- MultipleCmd::SubProc
- Defined in:
- lib/mcmd.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#pid ⇒ Object
Returns the value of attribute pid.
-
#retval ⇒ Object
Returns the value of attribute retval.
-
#stderr_buf ⇒ Object
Returns the value of attribute stderr_buf.
-
#stderr_fd ⇒ Object
Returns the value of attribute stderr_fd.
-
#stdin_fd ⇒ Object
Returns the value of attribute stdin_fd.
-
#stdout_buf ⇒ Object
Returns the value of attribute stdout_buf.
-
#stdout_fd ⇒ Object
Returns the value of attribute stdout_fd.
-
#terminated ⇒ Object
Returns the value of attribute terminated.
-
#time_end ⇒ Object
Returns the value of attribute time_end.
-
#time_start ⇒ Object
Returns the value of attribute time_start.
-
#write_buf_position ⇒ Object
Returns the value of attribute write_buf_position.
Instance Method Summary collapse
-
#initialize ⇒ SubProc
constructor
A new instance of SubProc.
-
#kill ⇒ Object
when a process has out-stayed its welcome.
-
#success? ⇒ Boolean
some heuristic to determine if this job was successful for now, trust retval.
Constructor Details
#initialize ⇒ SubProc
Returns a new instance of SubProc.
258 259 260 261 262 263 264 |
# File 'lib/mcmd.rb', line 258 def initialize self.write_buf_position = 0 self.time_start = Time.now.to_i self.stdout_buf = "" self.stderr_buf = "" self.terminated = false end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
256 257 258 |
# File 'lib/mcmd.rb', line 256 def command @command end |
#pid ⇒ Object
Returns the value of attribute pid.
256 257 258 |
# File 'lib/mcmd.rb', line 256 def pid @pid end |
#retval ⇒ Object
Returns the value of attribute retval.
256 257 258 |
# File 'lib/mcmd.rb', line 256 def retval @retval end |
#stderr_buf ⇒ Object
Returns the value of attribute stderr_buf.
256 257 258 |
# File 'lib/mcmd.rb', line 256 def stderr_buf @stderr_buf end |
#stderr_fd ⇒ Object
Returns the value of attribute stderr_fd.
255 256 257 |
# File 'lib/mcmd.rb', line 255 def stderr_fd @stderr_fd end |
#stdin_fd ⇒ Object
Returns the value of attribute stdin_fd.
255 256 257 |
# File 'lib/mcmd.rb', line 255 def stdin_fd @stdin_fd end |
#stdout_buf ⇒ Object
Returns the value of attribute stdout_buf.
256 257 258 |
# File 'lib/mcmd.rb', line 256 def stdout_buf @stdout_buf end |
#stdout_fd ⇒ Object
Returns the value of attribute stdout_fd.
255 256 257 |
# File 'lib/mcmd.rb', line 255 def stdout_fd @stdout_fd end |
#terminated ⇒ Object
Returns the value of attribute terminated.
256 257 258 |
# File 'lib/mcmd.rb', line 256 def terminated @terminated end |
#time_end ⇒ Object
Returns the value of attribute time_end.
256 257 258 |
# File 'lib/mcmd.rb', line 256 def time_end @time_end end |
#time_start ⇒ Object
Returns the value of attribute time_start.
256 257 258 |
# File 'lib/mcmd.rb', line 256 def time_start @time_start end |
#write_buf_position ⇒ Object
Returns the value of attribute write_buf_position.
255 256 257 |
# File 'lib/mcmd.rb', line 255 def write_buf_position @write_buf_position end |
Instance Method Details
#kill ⇒ Object
when a process has out-stayed its welcome
267 268 269 270 271 272 273 274 |
# File 'lib/mcmd.rb', line 267 def kill self.stdin_fd.close rescue true self.stdout_fd.close rescue true self.stderr_fd.close rescue true #TODO configurable sig? Process::kill("KILL", self.pid) self.terminated = true end |
#success? ⇒ Boolean
some heuristic to determine if this job was successful for now, trust retval. Also check stderr?
279 280 281 |
# File 'lib/mcmd.rb', line 279 def success? self.retval.success? end |