Skip to content

Commit

Permalink
Merge branch 'master' into leolost/animate-in-on-start
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 authored May 28, 2024
2 parents 957cae8 + 8645007 commit 4c5ecf8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/Dialogs.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
}

Expand Down
15 changes: 13 additions & 2 deletions src/ShellClients/ManagedClient.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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 {
Expand All @@ -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 ();

Expand All @@ -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
Expand Down

0 comments on commit 4c5ecf8

Please sign in to comment.