+ argp = custom_env_get_argp(&child_env);
+ envp = custom_env_get_envp(&child_env);
+
+ pid = fork();
+ switch (pid) {
+ case 0:
+ /* Put the client in a new session so it won't catch signals
+ * intended for the parent. Sharing a session can be
+ * confusing when launching weston under gdb, as the ctrl-c
+ * intended for gdb will pass to the child, and weston
+ * will cleanly shut down when the child exits.
+ */
+ setsid();
+
+ /* do not give our signal mask to the new process */
+ sigfillset(&allsigs);
+ sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
+
+ /* Launch clients as the user. Do not launch clients with wrong euid. */
+ if (seteuid(getuid()) == -1) {
+ written = write(STDERR_FILENO, fail_seteuid, strlen(fail_seteuid));
+ _exit(EXIT_FAILURE);
+ }
+
+ ret = fdstr_clear_cloexec_fd1(&wayland_socket);
+ if (!ret) {
+ written = write(STDERR_FILENO, fail_cloexec, strlen(fail_cloexec));
+ _exit(EXIT_FAILURE);
+ }
+
+ execve(argp[0], argp, envp);
+
+ if (fail_exec)
+ written = write(STDERR_FILENO, fail_exec, strlen(fail_exec));
+ _exit(EXIT_FAILURE);
+
+ default:
+ close(wayland_socket.fds[1]);
+ ivi = weston_compositor_get_user_data(compositor);
+ client = wl_client_create(compositor->wl_display,
+ wayland_socket.fds[0]);
+ if (!client) {
+ custom_env_fini(&child_env);
+ close(wayland_socket.fds[0]);
+ free(fail_exec);
+ weston_log("client_launch: "
+ "wl_client_create failed while launching '%s'.\n",
+ path);
+ return NULL;
+ }
+
+ proc->pid = pid;
+ proc->cleanup = cleanup;
+ wl_list_insert(&ivi->child_process_list, &proc->link);
+ break;
+
+ case -1:
+ fdstr_close_all(&wayland_socket);
+ weston_log("client_launch: "
+ "fork failed while launching '%s': %s\n", path,
+ strerror(errno));
+ break;