fix: unlink wayland socket manually instead of calling wl_display_destroy (wlroots 0.19 multi-backend aborts on display destroy during shutdown)

This commit is contained in:
lkn 2026-06-06 11:14:08 +02:00
parent 563b278268
commit bfa715a99e
1 changed files with 15 additions and 11 deletions

View File

@ -879,17 +879,21 @@ wl_display_close(void)
wl_state.cursor = NULL; wl_state.cursor = NULL;
} }
/* Tear down the Wayland display so the compositor socket is removed. /* Clean up the Wayland socket so a new compositor instance can bind.
* Without this, restart (execvp) fails because the new instance finds * wl_display_destroy() would do this, but in wlroots 0.19 it aborts
* a stale socket at $XDG_RUNTIME_DIR/wayland-N and refuses to start. * because the multi-backend's display-destroy handler iterates freed
* * child backend pointers. Since execvp replaces the entire process
* The XWayland server was SIGKILL'd above and server->client was * image, all memory and fd resources are reclaimed by the kernel.
* NULL'd to prevent wlr_xwayland_server_destroy from double-freeing * The socket file on disk is the only persistent resource we need
* the wl_client during display destroy signal dispatch. * to remove ourselves. */
* if (wl_state.socket_name[0]) {
* All remaining listeners were removed in the WL_LISTENER_REMOVE block const char *rt = getenv("XDG_RUNTIME_DIR");
* above, so no dangling signal handlers remain. */ if (rt) {
wl_display_destroy(wl_state.display); char path[256];
snprintf(path, sizeof(path), "%s/%s", rt, wl_state.socket_name);
unlink(path);
}
}
unsetenv("WAYLAND_DISPLAY"); unsetenv("WAYLAND_DISPLAY");
wl_state.renderer = NULL; wl_state.renderer = NULL;
wl_state.backend = NULL; wl_state.backend = NULL;