{
struct wlsc_compositor *ec = data;
+ fprintf(stderr, "caught signal %d\n", signal_number);
wl_display_terminate(ec->wl_display);
return 1;
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");
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);
struct wl_compositor compositor;
struct wl_shm *shm;
+ struct wlsc_xserver *wxs;
EGLDisplay display;
EGLContext context;
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
};
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;
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);
+}