parameters: (self, cmd, input='', timeout=None, buffer_output=False, track_memory=False, discard_stdout=False, discard_stderr=False, print_run_msg=False)
docstring: :returns: A quadruple (`memory`, `output`, `return_code`, `timeouted`).
docstring_summary: :returns: A quadruple (`memory`, `output`, `return_code`, `timeouted`).
docstring_tokens: : returns : A quadruple ( memory output return_code timeouted ) .
function: def _run_cmd(self, cmd, input='', timeout=None, buffer_output=False, track_memory=False, discard_stdout=False, discard_stderr=False, print_run_msg=False):
          """:returns: A quadruple (`memory`, `output`, `return_code`, `timeouted`)."""
          memory = 0
          try:
              output = ''
              if print_run_msg:
                  msg = 'RUN: ' + ' '.join(cmd)
                  if buffer_output:
                      output += msg + '\n'
                  else:
                      print(msg)
  
              track_memory = track_memory and tool_exists(config.LOG_TIME[0])
              if track_memory:
                  cmd = config.LOG_TIME + cmd
  
              p = self._start(cmd, buffer_output, discard_stdout=discard_stdout, discard_stderr=discard_stderr)
  
              def signal_handler(sig, frame):
                  p.kill()
                  sys.exit(1)
              signal.signal(signal.SIGINT, signal_handler)
              signal.signal(signal.SIGTERM, signal_handler)
  
              out, err = p.communicate(input, timeout)
  
              if out is not None:
                  output += out
              elif err is not None:
                  output += err
  
              if output:
                  output = output.rstrip()
                  output = self._strip_shell_colors(output)
                  if track_memory:
                      memory = self._get_memory_from_measured_output(output)
                      output = self._get_clean_output_from_measured_output(output)
  
              if p.returncode == 134 and output and 'std::bad_alloc' in output:
                  return memory, output, BAD_ALLOC_RC, False
  
              return memory, output, p.returncode, False
          except subprocess.TimeoutExpired:
              # Kill the process, along with all its child processes.
              p.kill()
              # Finish the communication to obtain the output.
              output, _ = p.communicate()
              if output:
                  output = output.rstrip()
                  output = self._strip_shell_colors(output)
              return memory, output, TIMEOUT_RC, True
function_tokens: def _run_cmd ( self , cmd , input = '' , timeout = None , buffer_output = False , track_memory = False , discard_stdout = False , discard_stderr = False , print_run_msg = False ) : memory = 0 try : output = '' if print_run_msg : msg = 'RUN: ' + ' ' . join ( cmd ) if buffer_output : output += msg + '\n' else : print ( msg ) track_memory = track_memory and tool_exists ( config . LOG_TIME [ 0 ] ) if track_memory : cmd = config . LOG_TIME + cmd p = self . _start ( cmd , buffer_output , discard_stdout = discard_stdout , discard_stderr = discard_stderr ) def signal_handler ( sig , frame ) : p . kill ( ) sys . exit ( 1 ) signal . signal ( signal . SIGINT , signal_handler ) signal . signal ( signal . SIGTERM , signal_handler ) out , err = p . communicate ( input , timeout ) if out is not None : output += out elif err is not None : output += err if output : output = output . rstrip ( ) output = self . _strip_shell_colors ( output ) if track_memory : memory = self . _get_memory_from_measured_output ( output ) output = self . _get_clean_output_from_measured_output ( output ) if p . returncode == 134 and output and 'std::bad_alloc' in output : return memory , output , BAD_ALLOC_RC , False return memory , output , p . returncode , False except subprocess . TimeoutExpired : # Kill the process, along with all its child processes. p . kill ( ) # Finish the communication to obtain the output. output , _ = p . communicate ( ) if output : output = output . rstrip ( ) output = self . _strip_shell_colors ( output ) return memory , output , TIMEOUT_RC , True