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.



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

#commandObject

Returns the value of attribute command.



256
257
258
# File 'lib/mcmd.rb', line 256

def command
  @command
end

#pidObject

Returns the value of attribute pid.



256
257
258
# File 'lib/mcmd.rb', line 256

def pid
  @pid
end

#retvalObject

Returns the value of attribute retval.



256
257
258
# File 'lib/mcmd.rb', line 256

def retval
  @retval
end

#stderr_bufObject

Returns the value of attribute stderr_buf.



256
257
258
# File 'lib/mcmd.rb', line 256

def stderr_buf
  @stderr_buf
end

#stderr_fdObject

Returns the value of attribute stderr_fd.



255
256
257
# File 'lib/mcmd.rb', line 255

def stderr_fd
  @stderr_fd
end

#stdin_fdObject

Returns the value of attribute stdin_fd.



255
256
257
# File 'lib/mcmd.rb', line 255

def stdin_fd
  @stdin_fd
end

#stdout_bufObject

Returns the value of attribute stdout_buf.



256
257
258
# File 'lib/mcmd.rb', line 256

def stdout_buf
  @stdout_buf
end

#stdout_fdObject

Returns the value of attribute stdout_fd.



255
256
257
# File 'lib/mcmd.rb', line 255

def stdout_fd
  @stdout_fd
end

#terminatedObject

Returns the value of attribute terminated.



256
257
258
# File 'lib/mcmd.rb', line 256

def terminated
  @terminated
end

#time_endObject

Returns the value of attribute time_end.



256
257
258
# File 'lib/mcmd.rb', line 256

def time_end
  @time_end
end

#time_startObject

Returns the value of attribute time_start.



256
257
258
# File 'lib/mcmd.rb', line 256

def time_start
  @time_start
end

#write_buf_positionObject

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

#killObject

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?

Returns:

  • (Boolean)


279
280
281
# File 'lib/mcmd.rb', line 279

def success?
  self.retval.success?
end