Skip to content

WaylandClient: create the wayland socket after fork

Jason Francis requested to merge jf/mutter:wayland-client-setup into main

This patch adds an additional socketpair call for WaylandClient into a child setup function. This changes the process for spawning a wayland client to:

  1. Create a socket pair in the server
  2. Pass one end to a child process
  3. Create another socket pair in the child process
  4. Send one end of the second socket pair back to the server with SCM_RIGHTS
  5. Replace the WAYLAND_SOCKET fd with the other new end (this is forced to fd 3)
  6. Once we receive the new fd in the server, then finally use it to call wl_client_create

This fixes two issues:

  1. The GSubprocessLauncher never holds the wayland client's fd, so this corrects the issue mentioned in !1450 (closed) where a WaylandClient process can hang because its socket is held open by the javascript runtime
  2. The SO_PEERCRED pid of the client now correctly gets set to the pid of the child process rather than to the pid of mutter. This is a partial fix for some issues mentioned in #1822, where force quitting a shell extension's WaylandClient window causes mutter to incorrectly SIGKILL itself.

Merge request reports