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.
257 258 259 260 261 262 263 |
# File 'lib/mcmd.rb', line 257 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.
255 256 257 |
# File 'lib/mcmd.rb', line 255 def command @command end |
#pid ⇒ Object
Returns the value of attribute pid.
255 256 257 |
# File 'lib/mcmd.rb', line 255 def pid @pid end |
#retval ⇒ Object
Returns the value of attribute retval.
255 256 257 |
# File 'lib/mcmd.rb', line 255 def retval @retval end |
#stderr_buf ⇒ Object
Returns the value of attribute stderr_buf.
255 256 257 |
# File 'lib/mcmd.rb', line 255 def stderr_buf @stderr_buf end |
#stderr_fd ⇒ Object
Returns the value of attribute stderr_fd.
254 255 256 |
# File 'lib/mcmd.rb', line 254 def stderr_fd @stderr_fd end |
#stdin_fd ⇒ Object
Returns the value of attribute stdin_fd.
254 255 256 |
# File 'lib/mcmd.rb', line 254 def stdin_fd @stdin_fd end |
#stdout_buf ⇒ Object
Returns the value of attribute stdout_buf.
255 256 257 |
# File 'lib/mcmd.rb', line 255 def stdout_buf @stdout_buf end |
#stdout_fd ⇒ Object
Returns the value of attribute stdout_fd.
254 255 256 |
# File 'lib/mcmd.rb', line 254 def stdout_fd @stdout_fd end |
#terminated ⇒ Object
Returns the value of attribute terminated.
255 256 257 |
# File 'lib/mcmd.rb', line 255 def terminated @terminated end |
#time_end ⇒ Object
Returns the value of attribute time_end.
255 256 257 |
# File 'lib/mcmd.rb', line 255 def time_end @time_end end |
#time_start ⇒ Object
Returns the value of attribute time_start.
255 256 257 |
# File 'lib/mcmd.rb', line 255 def time_start @time_start end |
#write_buf_position ⇒ Object
Returns the value of attribute write_buf_position.
254 255 256 |
# File 'lib/mcmd.rb', line 254 def write_buf_position @write_buf_position end |
Instance Method Details
#kill ⇒ Object
when a process has out-stayed its welcome
266 267 268 269 270 271 272 273 |
# File 'lib/mcmd.rb', line 266 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?
278 279 280 |
# File 'lib/mcmd.rb', line 278 def success? self.retval.success? end |