WaylandClient: create the wayland socket after fork
This patch adds an additional socketpair
call for WaylandClient
into a child setup function. This changes the process for spawning a wayland client to:
- Create a socket pair in the server
- Pass one end to a child process
- Create another socket pair in the child process
- Send one end of the second socket pair back to the server with
SCM_RIGHTS
- Replace the
WAYLAND_SOCKET
fd with the other new end (this is forced to fd 3) - Once we receive the new fd in the server, then finally use it to call
wl_client_create
This fixes two issues:
- The
GSubprocessLauncher
never holds the wayland client's fd, so this corrects the issue mentioned in !1450 (closed) where aWaylandClient
process can hang because its socket is held open by the javascript runtime - 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'sWaylandClient
window causes mutter to incorrectlySIGKILL
itself.