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>
This commit is contained in:
Pekka Paalanen
2022-07-07 11:15:42 +03:00
committed by Pekka Paalanen
parent e88a622434
commit 71b40fc76b
+6 -4
View File
@@ -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;
}