frontend: Move path into weston_process

We have this everywhere, so we can move it out of process_info.

Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Daniel Stone 2023-04-18 13:25:13 +01:00
parent 2a9f7aabdb
commit ca55f0549b
2 changed files with 9 additions and 14 deletions

View File

@ -361,6 +361,7 @@ sigchld_handler(int signal_number, void *data)
wl_list_remove(&p->link);
wl_list_init(&p->link);
free(p->path);
p->cleanup(p, status);
}
@ -443,6 +444,7 @@ weston_client_launch(struct weston_compositor *compositor,
default:
proc->pid = pid;
proc->cleanup = cleanup;
proc->path = strdup(argp[0]);
wet_watch_process(compositor, proc);
ret = true;
break;
@ -470,7 +472,6 @@ wet_watch_process(struct weston_compositor *compositor,
struct process_info {
struct weston_process proc;
char *path;
};
static void
@ -485,16 +486,15 @@ process_handle_sigchld(struct weston_process *process, int status)
*/
if (WIFEXITED(status)) {
weston_log("%s exited with status %d\n", pinfo->path,
weston_log("%s exited with status %d\n", process->path,
WEXITSTATUS(status));
} else if (WIFSIGNALED(status)) {
weston_log("%s died on signal %d\n", pinfo->path,
weston_log("%s died on signal %d\n", process->path,
WTERMSIG(status));
} else {
weston_log("%s disappeared\n", pinfo->path);
weston_log("%s disappeared\n", process->path);
}
free(pinfo->path);
free(pinfo);
}
@ -513,16 +513,12 @@ weston_client_start(struct weston_compositor *compositor, const char *path)
if (!pinfo)
return NULL;
pinfo->path = strdup(path);
if (!pinfo->path)
goto out_free;
if (os_socketpair_cloexec(AF_UNIX, SOCK_STREAM, 0,
wayland_socket.fds) < 0) {
weston_log("weston_client_start: "
"socketpair failed while launching '%s': %s\n",
path, strerror(errno));
goto out_path;
goto err;
}
custom_env_init_from_environ(&child_env);
@ -539,7 +535,7 @@ weston_client_start(struct weston_compositor *compositor, const char *path)
no_cloexec_fds, num_no_cloexec_fds,
process_handle_sigchld);
if (!ret)
goto out_path;
goto err;
client = wl_client_create(compositor->wl_display,
wayland_socket.fds[0]);
@ -556,9 +552,7 @@ weston_client_start(struct weston_compositor *compositor, const char *path)
return client;
out_path:
free(pinfo->path);
out_free:
err:
free(pinfo);
out_sock:
fdstr_close_all(&wayland_socket);

View File

@ -42,6 +42,7 @@ typedef void (*weston_process_cleanup_func_t)(struct weston_process *process,
struct weston_process {
pid_t pid;
char *path;
weston_process_cleanup_func_t cleanup;
struct wl_list link;
};