aboutsummaryrefslogtreecommitdiff
path: root/xwayland/xwayland.c
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2017-08-23 23:19:15 +0200
committerDominique Martinet <asmadeus@codewreck.org>2017-08-24 07:51:24 +0200
commite3143b50b6363bb7408e30aa64acdbdcd9b249d9 (patch)
treececfe4fc588c797c8824cbda18389fdacbef7a11 /xwayland/xwayland.c
parentfd3ad3b9e42d9f2d1196a5c36b07763283729053 (diff)
xwayland: fix some shutdown cases
Diffstat (limited to 'xwayland/xwayland.c')
-rw-r--r--xwayland/xwayland.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c
index 9c0b1839..9ac94e72 100644
--- a/xwayland/xwayland.c
+++ b/xwayland/xwayland.c
@@ -6,6 +6,8 @@
#include <fcntl.h>
#include <signal.h>
#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/wait.h>
#include <time.h>
#include <stdlib.h>
#include <errno.h>
@@ -93,9 +95,9 @@ static void exec_xwayland(struct wlr_xwayland *wlr_xwayland) {
snprintf(wayland_socket_str, sizeof(wayland_socket_str), "%d", wlr_xwayland->wl_fd[1]);
setenv("WAYLAND_SOCKET", wayland_socket_str, true);
- wlr_log(L_INFO, "Xwayland :%d -rootless -terminate -listen %d -listen %d -wm %d",
- wlr_xwayland->display, wlr_xwayland->x_fd[0], wlr_xwayland->x_fd[1],
- wlr_xwayland->wm_fd[1]);
+ wlr_log(L_INFO, "WAYLAND_SOCKET=%d Xwayland :%d -rootless -terminate -listen %d -listen %d -wm %d",
+ wlr_xwayland->wl_fd[1], wlr_xwayland->display, wlr_xwayland->x_fd[0],
+ wlr_xwayland->x_fd[1], wlr_xwayland->wm_fd[1]);
// TODO: close stdout/err depending on log level
@@ -111,20 +113,23 @@ static void xwayland_destroy_event(struct wl_listener *listener, void *data) {
/* don't call client destroy */
wlr_xwayland->client = NULL;
+ wl_list_remove(&wlr_xwayland->destroy_listener.link);
wlr_xwayland_finish(wlr_xwayland);
- if (wlr_xwayland->server_start - time(NULL) > 5) {
+ if (time(NULL) - wlr_xwayland->server_start > 5) {
wlr_xwayland_init(wlr_xwayland, wlr_xwayland->wl_display,
- wlr_xwayland->compositor);
+ wlr_xwayland->compositor);
}
}
static void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland) {
+ if (!wlr_xwayland || wlr_xwayland->display == -1) {
+ return;
+ }
if (wlr_xwayland->client) {
wl_list_remove(&wlr_xwayland->destroy_listener.link);
wl_client_destroy(wlr_xwayland->client);
}
-
if (wlr_xwayland->sigusr1_source) {
wl_event_source_remove(wlr_xwayland->sigusr1_source);
}
@@ -142,10 +147,13 @@ static void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland) {
safe_close(wlr_xwayland->wm_fd[1]);
unlink_display_sockets(wlr_xwayland->display);
+ wlr_xwayland->display = -1;
unsetenv("DISPLAY");
- /* We do not kill the Xwayland process, it dies because of broken pipe
- * after we close our side of the wm/wl fds. This is more reliable than
- * trying to kill something that might no longer be Xwayland */
+ /* We do not kill the Xwayland process, it dies to broken pipe
+ * after we close our side of the wm/wl fds. This is more reliable
+ * than trying to kill something that might no longer be Xwayland.
+ */
+ // TODO: figure how to wait for dying process though. Probably handle SIGCHILD
}
static int xserver_handle_ready(int signal_number, void *data) {