Class: MultipleCmd::SubProc

Inherits:
Object
  • Object
show all
Defined in:
lib/mcmd.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSubProc

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

#commandObject

Returns the value of attribute command.



259
260
261
# File 'lib/mcmd.rb', line 259

def command
  @command
end

#pidObject

Returns the value of attribute pid.



259
260
261
# File 'lib/mcmd.rb', line 259

def pid
  @pid
end

#retvalObject

Returns the value of attribute retval.



259
260
261
# File 'lib/mcmd.rb', line 259

def retval
  @retval
end

#stderr_bufObject

Returns the value of attribute stderr_buf.



259
260
261
# File 'lib/mcmd.rb', line 259

def stderr_buf
  @stderr_buf
end

#stderr_fdObject

Returns the value of attribute stderr_fd.



258
259
260
# File 'lib/mcmd.rb', line 258

def stderr_fd
  @stderr_fd
end

#stdin_fdObject

Returns the value of attribute stdin_fd.



258
259
260
# File 'lib/mcmd.rb', line 258

def stdin_fd
  @stdin_fd
end

#stdout_bufObject

Returns the value of attribute stdout_buf.



259
260
261
# File 'lib/mcmd.rb', line 259

def stdout_buf
  @stdout_buf
end

#stdout_fdObject

Returns the value of attribute stdout_fd.



258
259
260
# File 'lib/mcmd.rb', line 258

def stdout_fd
  @stdout_fd
end

#terminatedObject

Returns the value of attribute terminated.



259
260
261
# File 'lib/mcmd.rb', line 259

def terminated
  @terminated
end

#time_endObject

Returns the value of attribute time_end.



259
260
261
# File 'lib/mcmd.rb', line 259

def time_end
  @time_end
end

#time_startObject

Returns the value of attribute time_start.



259
260
261
# File 'lib/mcmd.rb', line 259

def time_start
  @time_start
end

#write_buf_positionObject

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

#killObject

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?

Returns:



282
283
284
# File 'lib/mcmd.rb', line 282

def success?
  self.retval.success?
end