meego-tablet-shell: Use central sigchild handler

dev
Kristian Høgsberg 14 years ago
parent 27da538ab5
commit d4af320178
  1. 28
      compositor/meego-tablet-shell.c

@ -52,8 +52,7 @@ struct meego_tablet_shell {
struct wlsc_shell shell; struct wlsc_shell shell;
struct wlsc_compositor *compositor; struct wlsc_compositor *compositor;
struct wl_event_source *sigchld_source; struct wlsc_process process;
pid_t pid;
struct wlsc_input_device *device; struct wlsc_input_device *device;
struct wl_client *client; struct wl_client *client;
@ -92,18 +91,16 @@ struct meego_tablet_zoom {
void (*done)(struct meego_tablet_zoom *zoom); void (*done)(struct meego_tablet_zoom *zoom);
}; };
static int
sigchld_handler(int signal_number, void *data) static void
meego_tablet_shell_sigchld(struct wlsc_process *process, int status)
{ {
struct meego_tablet_shell *shell = data; struct meego_tablet_shell *shell =
int status; container_of(process, struct meego_tablet_shell, process);
wait(&status); shell->process.pid = 0;
shell->pid = 0;
fprintf(stderr, "meego-ux-daemon crashed, exit code %d\n", status); fprintf(stderr, "meego-ux-daemon crashed, exit code %d\n", status);
return 1;
} }
static void static void
@ -473,8 +470,10 @@ launch_ux_daemon(struct meego_tablet_shell *shell)
return; return;
} }
shell->pid = fork(); shell->process.pid = fork();
switch (shell->pid) { shell->process.cleanup = meego_tablet_shell_sigchld;
switch (shell->process.pid) {
case 0: case 0:
/* SOCK_CLOEXEC closes both ends, so we need to unset /* SOCK_CLOEXEC closes both ends, so we need to unset
* the flag on the client fd. */ * the flag on the client fd. */
@ -495,6 +494,7 @@ launch_ux_daemon(struct meego_tablet_shell *shell)
close(sv[1]); close(sv[1]);
shell->client = shell->client =
wl_client_create(compositor->wl_display, sv[0]); wl_client_create(compositor->wl_display, sv[0]);
wlsc_watch_process(&shell->process);
break; break;
case -1: case -1:
@ -640,10 +640,6 @@ shell_init(struct wlsc_compositor *compositor)
wl_display_add_global(compositor->wl_display, &shell->object, NULL); wl_display_add_global(compositor->wl_display, &shell->object, NULL);
loop = wl_display_get_event_loop(compositor->wl_display); loop = wl_display_get_event_loop(compositor->wl_display);
shell->sigchld_source =
wl_event_loop_add_signal(loop, SIGCHLD,
sigchld_handler, shell);
shell->long_press_source = shell->long_press_source =
wl_event_loop_add_timer(loop, long_press_handler, shell); wl_event_loop_add_timer(loop, long_press_handler, shell);

Loading…
Cancel
Save