xwayland: move config reading up

Doing any kind of memory allocation calls between fork() and exec() in
the child process is prone to deadlocks and explosions. In general, only
async-signal-safe functions are safe there.

Move the config access to the parent process before fork() to avoid
problems.

See also:
https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/941#note_1457053

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 2 years ago committed by Pekka Paalanen
parent e88a622434
commit 71b40fc76b
  1. 10
      compositor/xwayland.c

@ -140,13 +140,13 @@ spawn_xserver(void *user_data, const char *display, int abstract_fd, int unix_fd
return 1;
}
section = weston_config_get_section(config, "xwayland", NULL, NULL);
weston_config_section_get_string(section, "path",
&xserver, XSERVER_PATH);
pid = fork();
switch (pid) {
case 0:
section = weston_config_get_section(config,
"xwayland", NULL, NULL);
weston_config_section_get_string(section, "path",
&xserver, XSERVER_PATH);
/* SOCK_CLOEXEC closes both ends, so we need to unset
* the flag on the client fd. */
@ -205,6 +205,8 @@ spawn_xserver(void *user_data, const char *display, int abstract_fd, int unix_fd
break;
}
free(xserver);
return pid;
}

Loading…
Cancel
Save