code: def start_standing_subprocess(cmd, shell=False, env=None):
      
      logging.debug('Starting standing subprocess with: %s', cmd)
      proc = subprocess.Popen(
          cmd,
          stdin=subprocess.PIPE,
          stdout=subprocess.PIPE,
          stderr=subprocess.PIPE,
          shell=shell,
          env=env)
      # Leaving stdin open causes problems for input, e.g. breaking the
      # code.inspect() shell (http://stackoverflow.com/a/25512460/1612937), so
      # explicitly close it assuming it is not needed for standing subprocesses.
      proc.stdin.close()
      proc.stdin = None
      logging.debug('Started standing subprocess %d', proc.pid)
      return proc
docs: Starts a long-running subprocess.
  
      This is not a blocking call and the subprocess started by it should be
      explicitly terminated with stop_standing_subprocess.
  
      For short-running commands, you should use subprocess.check_call, which
      blocks.
  
      Args:
          cmd: string, the command to start the subprocess with.
          shell: bool, True to run this command through the system shell,
              False to invoke it directly. See subprocess.Proc() docs.
          env: dict, a custom environment to run the standing subprocess. If not
              specified, inherits the current environment. See subprocess.Popen()
              docs.
  
      Returns:
          The subprocess that was started.