code: def getpid(target=None, host=None, all=False, **kwds):
      """get the process id for a target process (possibly) running on remote host
  
      This method should only be used as a last-ditch effort to find a process id.
      This method __may__ work when a child has been spawned and the pid was not
      registered... but there's no guarantee.
  
      If target is None, then get the process id of the __main__  python instance.
  
      Args:
          target -- string name of target process
          host   -- hostname where process is running
          all    -- get all resulting lines from query?  [default = False]
      """
      if target is None:
          if all:
              target = ""
          elif host:
              raise OSError("[Error 3] No such process")
          else:
              return os.getpid()
      elif isinstance(
          target, int
      ):  # NOTE: passing pid useful for all=True
          target = "%5d " % target  # NOTE: assumes max pid is 99999
      # command = "ps -A | grep '%s'" % target # 'other users' only
      command = "ps ax | grep '%s'" % target  # 'all users'
      response = _psax(
          execute(command, host, bg=False, **kwds).response()
      )
      ignore = "grep %s" % target
      if all:
          return response
  
      try:  # select the PID
          # find most recent where "grep '%s'" not in line
          pid = sorted(
              _select(line, (0,))[0]
              for line in response.split("\n")
              if line and ignore not in line and command not in line
          )
          if pid is None:
              raise OSError("Failure to recover process id")
          # XXX: take advantage of *ppid to help match correct pid?
          return int(pid[-1])
      except (AttributeError, IndexError):
          raise OSError("[Error 3] No such process")
  
file_path: pathos/pathos/core.py
imports: import os
  import string
  import re
  import pathos
label_desc: Use image node_id 5 for calling a global function with example usage: getpid(target, host, all) and returns: response, int, os