From d1b01ffb9a5f212fb6d4deb151f1b5016e5d61e1 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Thu, 7 Jul 2022 14:52:20 +0300 Subject: [PATCH] xwayland: use execv() Constructing argv before-hand is a little easier to look at, but this is mostly just anticipating more changes to how Weston spawns processes in general. Signed-off-by: Pekka Paalanen --- compositor/xwayland.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/compositor/xwayland.c b/compositor/xwayland.c index 49841aef..2042b6b8 100644 --- a/compositor/xwayland.c +++ b/compositor/xwayland.c @@ -170,6 +170,18 @@ spawn_xserver(void *user_data, const char *display, int abstract_fd, int unix_fd str_printf(&exec_failure_msg, "Error: executing Xwayland as '%s' failed.\n", xserver); + const char *const argv[] = { + xserver, + display, + "-rootless", + LISTEN_STR, x11_abstract_socket.str1, + LISTEN_STR, x11_unix_socket.str1, + "-displayfd", display_pipe.str1, + "-wm", x11_wm_socket.str1, + "-terminate", + NULL + }; + pid = fork(); switch (pid) { case 0: @@ -185,21 +197,13 @@ spawn_xserver(void *user_data, const char *display, int abstract_fd, int unix_fd setenv("WAYLAND_SOCKET", wayland_socket.str1, 1); - if (execl(xserver, - xserver, - display, - "-rootless", - LISTEN_STR, x11_abstract_socket.str1, - LISTEN_STR, x11_unix_socket.str1, - "-displayfd", display_pipe.str1, - "-wm", x11_wm_socket.str1, - "-terminate", - NULL) < 0) { + if (execv(xserver, (char *const *)argv) < 0) { if (exec_failure_msg) { write(STDERR_FILENO, exec_failure_msg, strlen(exec_failure_msg)); } } + _exit(EXIT_FAILURE); default: