xserver: Clean up X server socket on exit
This commit is contained in:
parent
fcf6577108
commit
3cad436a91
@ -1961,6 +1961,7 @@ static int on_term_signal(int signal_number, void *data)
|
||||
{
|
||||
struct wlsc_compositor *ec = data;
|
||||
|
||||
fprintf(stderr, "caught signal %d\n", signal_number);
|
||||
wl_display_terminate(ec->wl_display);
|
||||
|
||||
return 1;
|
||||
@ -2089,7 +2090,7 @@ int main(int argc, char *argv[])
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
if (xserver)
|
||||
wlsc_xserver_init(display);
|
||||
wlsc_xserver_init(ec);
|
||||
|
||||
if (wl_display_add_socket(display, option_socket_name)) {
|
||||
fprintf(stderr, "failed to add socket: %m\n");
|
||||
@ -2099,12 +2100,16 @@ int main(int argc, char *argv[])
|
||||
loop = wl_display_get_event_loop(ec->wl_display);
|
||||
wl_event_loop_add_signal(loop, SIGTERM, on_term_signal, ec);
|
||||
wl_event_loop_add_signal(loop, SIGINT, on_term_signal, ec);
|
||||
wl_event_loop_add_signal(loop, SIGQUIT, on_term_signal, ec);
|
||||
|
||||
wl_list_init(&child_process_list);
|
||||
wl_event_loop_add_signal(loop, SIGCHLD, sigchld_handler, NULL);
|
||||
|
||||
wl_display_run(display);
|
||||
|
||||
if (xserver)
|
||||
wlsc_xserver_destroy(ec);
|
||||
|
||||
if (ec->has_bind_display)
|
||||
ec->unbind_display(ec->display, display);
|
||||
wl_display_destroy(display);
|
||||
|
@ -160,6 +160,7 @@ struct wlsc_compositor {
|
||||
struct wl_compositor compositor;
|
||||
|
||||
struct wl_shm *shm;
|
||||
struct wlsc_xserver *wxs;
|
||||
|
||||
EGLDisplay display;
|
||||
EGLContext context;
|
||||
@ -397,6 +398,8 @@ void
|
||||
wlsc_watch_process(struct wlsc_process *process);
|
||||
|
||||
int
|
||||
wlsc_xserver_init(struct wl_display *display);
|
||||
wlsc_xserver_init(struct wlsc_compositor *compositor);
|
||||
void
|
||||
wlsc_xserver_destroy(struct wlsc_compositor *compositor);
|
||||
|
||||
#endif
|
||||
|
@ -549,8 +549,9 @@ static const struct xserver_interface xserver_implementation = {
|
||||
};
|
||||
|
||||
int
|
||||
wlsc_xserver_init(struct wl_display *display)
|
||||
wlsc_xserver_init(struct wlsc_compositor *compositor)
|
||||
{
|
||||
struct wl_display *display = compositor->wl_display;
|
||||
struct wlsc_xserver *mxs;
|
||||
char lockfile[256], pid[16], *end;
|
||||
socklen_t size, name_size;
|
||||
@ -656,5 +657,22 @@ wlsc_xserver_init(struct wl_display *display)
|
||||
wl_display_add_global(display,
|
||||
&mxs->xserver.object, wlsc_xserver_bind);
|
||||
|
||||
compositor->wxs = mxs;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
wlsc_xserver_destroy(struct wlsc_compositor *compositor)
|
||||
{
|
||||
struct wlsc_xserver *wxs = compositor->wxs;
|
||||
char path[256];
|
||||
|
||||
snprintf(path, sizeof path, "/tmp/.X%d-lock", wxs->display);
|
||||
unlink(path);
|
||||
snprintf(path, sizeof path, "/tmp/.X11-unix/X%d", wxs->display);
|
||||
unlink(path);
|
||||
close(wxs->fd);
|
||||
wl_event_source_remove(wxs->source);
|
||||
free(wxs);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user