Skip to content
Commit 8aa8f712 authored by Sergio Costas's avatar Sergio Costas
Browse files

Close local FDs in the launcher

GLib 2.68 added a method in SubprocessLauncher that allows to
close in the parent space all the FDs passed to the child.
Previously this was done automagically on object destruction,
but in languages with garbage collector like Javascript, this
happens in an indeterminated time, which means that the
descriptors can remain opened in the parent space for a long
time after the SubprocessLauncher is no longer needed.

In this case, the FD is one side of the socket used to
communicate the child with the Wayland server, and since if an
FD is shared between child and parent, it must be closed in
both spaces to guarantee that the socket considers it closed,
this means that if the child closes its FD, but the Subprocess-
Launcher hasn't still be reclaimed by the GC, the socket will
remain open.

The problem is that, if the socket is open, the Wayland server
can't destroy any resource created over that socket, like a
Wayland Surface (aka: a window). Thus, if the child process
dies before the SubprocessLauncher has been reclaimed by the
GC, the connection will remain active and any window left by
the child process will remain in the screen, but completely
"dead": it wouldn't be possible to close it, or interact with
it, only wait until the GC reclaims the SubprocessLauncher.
This is why DING captures the SIGINT signal and destroys all
the windows before exiting.

But with this new method added in GLib 2.68, it is possible
to ask the SubprocessLauncher to close all the FDs in the
parent side, thus fixing this problem.

This MR just implements the call to this method, but checking
before if it is available, to ensure compatibility with
Gnome Shell 3.38, which uses GLib 2.66.
parent cbde40d1
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment