code: def get_peercred(sock):
      
      buf = sock.getsockopt(_PEERCRED_LEVEL, _PEERCRED_OPTION, struct.calcsize('3i'))
      return struct.unpack('3i', buf)
docs: Gets the (pid, uid, gid) for the client on the given *connected* socket.