code: def _exec_command(command, use_shell=None, use_tee=None, **env):
      """
      Internal workhorse for exec_command().
      """
      if use_shell is None:
          use_shell = os.name == "posix"
      if use_tee is None:
          use_tee = os.name == "posix"
  
      if os.name == "posix" and use_shell:
          # On POSIX, subprocess always uses /bin/sh, override
          sh = os.environ.get("SHELL", "/bin/sh")
          if is_sequence(command):
              command = [sh, "-c", " ".join(command)]
          else:
              command = [sh, "-c", command]
          use_shell = False
  
      elif os.name == "nt" and is_sequence(command):
          # On Windows, join the string for CreateProcess() ourselves as
          # subprocess does it a bit differently
          command = " ".join(_quote_arg(arg) for arg in command)
  
      # Inherit environment by default
      env = env or None
      try:
          # text is set to False so that communicate()
          # will return bytes. We need to decode the output ourselves
          # so that Python will not raise a UnicodeDecodeError when
          # it encounters an invalid character; rather, we simply replace it
          proc = subprocess.Popen(
              command,
              shell=use_shell,
              env=env,
              text=False,
              stdout=subprocess.PIPE,
              stderr=subprocess.STDOUT,
          )
      except OSError:
          # Return 127, as os.spawn*() and /bin/sh do
          return 127, ""
  
      text, err = proc.communicate()
      mylocale = locale.getpreferredencoding(False)
      if mylocale is None:
          mylocale = "ascii"
      text = text.decode(mylocale, errors="replace")
      text = text.replace("\r\n", "\n")
      # Another historical oddity
      if text[-1:] == "\n":
          text = text[:-1]
  
      if use_tee and text:
          print(text)
      return proc.returncode, text
  
file_path: numpy/numpy/distutils/exec_command.py
imports: import os
  import sys
  import subprocess
  import locale
  import warnings
  from numpy.distutils.misc_util import is_sequence, make_temp_file
  from numpy.distutils import log
label_desc: Use image node_id 9 for calling a global function with example usage: _exec_command(command, use_shell, use_tee) and returns: proc,  text, int,  str