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.
261 262 263 264 265 266 267 |
# File 'lib/mcmd.rb', line 261 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.
259 260 261 |
# File 'lib/mcmd.rb', line 259 def command @command end |
#pid ⇒ Object
Returns the value of attribute pid.
259 260 261 |
# File 'lib/mcmd.rb', line 259 def pid @pid end |
#retval ⇒ Object
Returns the value of attribute retval.
259 260 261 |
# File 'lib/mcmd.rb', line 259 def retval @retval end |
#stderr_buf ⇒ Object
Returns the value of attribute stderr_buf.
259 260 261 |
# File 'lib/mcmd.rb', line 259 def stderr_buf @stderr_buf end |
#stderr_fd ⇒ Object
Returns the value of attribute stderr_fd.
258 259 260 |
# File 'lib/mcmd.rb', line 258 def stderr_fd @stderr_fd end |
#stdin_fd ⇒ Object
Returns the value of attribute stdin_fd.
258 259 260 |
# File 'lib/mcmd.rb', line 258 def stdin_fd @stdin_fd end |
#stdout_buf ⇒ Object
Returns the value of attribute stdout_buf.
259 260 261 |
# File 'lib/mcmd.rb', line 259 def stdout_buf @stdout_buf end |
#stdout_fd ⇒ Object
Returns the value of attribute stdout_fd.
258 259 260 |
# File 'lib/mcmd.rb', line 258 def stdout_fd @stdout_fd end |
#terminated ⇒ Object
Returns the value of attribute terminated.
259 260 261 |
# File 'lib/mcmd.rb', line 259 def terminated @terminated end |
#time_end ⇒ Object
Returns the value of attribute time_end.
259 260 261 |
# File 'lib/mcmd.rb', line 259 def time_end @time_end end |
#time_start ⇒ Object
Returns the value of attribute time_start.
259 260 261 |
# File 'lib/mcmd.rb', line 259 def time_start @time_start end |
#write_buf_position ⇒ Object
Returns the value of attribute write_buf_position.
258 259 260 |
# File 'lib/mcmd.rb', line 258 def write_buf_position @write_buf_position end |
Instance Method Details
#kill ⇒ Object
when a process has out-stayed its welcome
270 271 272 273 274 275 276 277 |
# File 'lib/mcmd.rb', line 270 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?
282 283 284 |
# File 'lib/mcmd.rb', line 282 def success? self.retval.success? end |