- pid = fork();
- switch (pid) {
- case 0:
- /* SOCK_CLOEXEC closes both ends, so we need to unset
- * the flag on the client fd. */
- fd = dup(sv[1]);
- if (fd < 0)
- goto fail;
- snprintf(s, sizeof s, "%d", fd);
- setenv("WAYLAND_SOCKET", s, 1);
-
- fd = dup(abstract_fd);
- if (fd < 0)
- goto fail;
- snprintf(abstract_fd_str, sizeof abstract_fd_str, "%d", fd);
- fd = dup(unix_fd);
- if (fd < 0)
- goto fail;
- snprintf(unix_fd_str, sizeof unix_fd_str, "%d", fd);
- fd = dup(wm[1]);
- if (fd < 0)
- goto fail;
- snprintf(wm_fd_str, sizeof wm_fd_str, "%d", fd);
-
- section = weston_config_get_section(config,
- "xwayland", NULL, NULL);
- weston_config_section_get_string(section, "path",
- &xserver, XSERVER_PATH);
-
- /* Ignore SIGUSR1 in the child, which will make the X
- * server send SIGUSR1 to the parent (weston) when
- * it's done with initialization. During
- * initialization the X server will round trip and
- * block on the wayland compositor, so avoid making
- * blocking requests (like xcb_connect_to_fd) until
- * it's done with that. */
- signal(SIGUSR1, SIG_IGN);
-
- if (execl(xserver,
- xserver,
- display,
- "-rootless",
-#ifdef HAVE_XWAYLAND_LISTENFD
- "-listenfd", abstract_fd_str,
- "-listenfd", unix_fd_str,
-#else
- "-listen", abstract_fd_str,
- "-listen", unix_fd_str,
-#endif
- "-wm", wm_fd_str,
- "-terminate",
- NULL) < 0)
- weston_log("exec of '%s %s -rootless "
-#ifdef HAVE_XWAYLAND_LISTENFD
- "-listenfd %s -listenfd %s "
-#else
- "-listen %s -listen %s "
-#endif
- "-wm %s -terminate' failed: %s\n",
- xserver, display,
- abstract_fd_str, unix_fd_str, wm_fd_str,
- strerror(errno));
- fail:
- _exit(EXIT_FAILURE);