code: def process_from_address(addr, port, torstate=None):
      
  
      if addr is None:
          return None
  
      if "(tor_internal)" == str(addr).lower():
          if torstate is None:
              return None
          return int(torstate.tor_pid)
  
      proc = subprocess.Popen(['lsof', '-i', '4tcp@%s:%s' % (addr, port)],
                              stdout=subprocess.PIPE)
      (stdout, stderr) = proc.communicate()
      lines = stdout.split(b'\n')
      if len(lines) > 1:
          return int(lines[1].split()[1])
docs: Determines the PID from the address/port provided by using lsof
      and returns it as an int (or None if it couldn't be
      determined). In the special case the addr is '(Tor_internal)' then
      the PID of the Tor process (as gotten from the torstate object) is
      returned (or 0 if unavailable, e.g. a Tor which doesn't implement
      'GETINFO process/pid'). In this case if no TorState instance is
      given, None is returned.