code: def exec_args(args, in_data='', chdir=None, shell=None, emulate_tty=False):
      
      LOG.debug('exec_args(%r, ..., chdir=%r)', args, chdir)
      assert isinstance(args, list)
  
      if emulate_tty:
          stderr = subprocess.STDOUT
      else:
          stderr = subprocess.PIPE
  
      proc = subprocess.Popen(
          args=args,
          stdout=subprocess.PIPE,
          stderr=stderr,
          stdin=subprocess.PIPE,
          cwd=chdir,
      )
      stdout, stderr = proc.communicate(in_data)
  
      if emulate_tty:
          stdout = stdout.replace(b('\n'), b('\r\n'))
      return proc.returncode, stdout, stderr or b('')
docs: Run a command in a subprocess, emulating the argument handling behaviour of
      SSH.
  
      :param list[str]:
          Argument vector.
      :param bytes in_data:
          Optional standard input for the command.
      :param bool emulate_tty:
          If :data:`True`, arrange for stdout and stderr to be merged into the
          stdout pipe and for LF to be translated into CRLF, emulating the
          behaviour of a TTY.
      :return:
          (return code, stdout bytes, stderr bytes)