Avoid ending our own process (#1919)

This commit is contained in:
Leonhard 2024-05-28 20:01:43 +02:00 committed by GitHub
parent 3a40014d6a
commit 8645007bff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 2 deletions

View File

@ -172,6 +172,18 @@ namespace Gala {
return;
}
try {
var our_pid = new Credentials ().get_unix_pid ();
if (our_pid == window.get_pid ()) {
critical ("We have an unresponsive window somewhere. Mutter wants to end its own process. Don't let it.");
// In all seriousness this sounds bad, but can happen if one of our WaylandClients gets unresponsive.
on_response (1);
return;
}
} catch (Error e) {
warning ("Failed to safeguard kill pid: %s", e.message);
}
base.show ();
}

View File

@ -18,6 +18,8 @@ public class Gala.ManagedClient : Object {
public Meta.WaylandClient? wayland_client { get; private set; }
private Subprocess? subprocess;
public ManagedClient (Meta.Display display, string[] args) {
Object (display: display, args: args);
}
@ -29,6 +31,15 @@ public class Gala.ManagedClient : Object {
display.window_created.connect ((window) => {
if (wayland_client != null && wayland_client.owns_window (window)) {
window_created (window);
// We have to manage is alive manually since windows created by WaylandClients have our pid
// and we don't want to end our own process
window.notify["is-alive"].connect (() => {
if (!window.is_alive && subprocess != null) {
subprocess.force_exit ();
warning ("WaylandClient window became unresponsive, killing the client.");
}
});
}
});
} else {
@ -44,7 +55,7 @@ public class Gala.ManagedClient : Object {
#else
wayland_client = new Meta.WaylandClient (subprocess_launcher);
#endif
var subprocess = wayland_client.spawnv (display, args);
subprocess = wayland_client.spawnv (display, args);
yield subprocess.wait_async ();
@ -61,7 +72,7 @@ public class Gala.ManagedClient : Object {
private async void start_x () {
try {
var subprocess = new Subprocess.newv (args, NONE);
subprocess = new Subprocess.newv (args, NONE);
yield subprocess.wait_async ();
//Restart the daemon if it crashes