module Mixlib::ShellOut::Unix

def reap_errant_child

def reap_errant_child
  return if attempt_reap
  @terminate_reason = "Command exceeded allowed execution time, process terminated"
  logger.error("Command exceeded allowed execution time, sending TERM") if logger
  Process.kill(:TERM, child_pgid)
  sleep 3
  attempt_reap
  logger.error("Command exceeded allowed execution time, sending KILL") if logger
  Process.kill(:KILL, child_pgid)
  reap
  # Should not hit this but it's possible if something is calling waitall
  # in a separate thread.
rescue Errno::ESRCH
  nil
end