[PATCH weston v2] Added handler for SIGABRT
Giulio Camuffo
giuliocamuffo at gmail.com
Wed Mar 27 14:20:39 PDT 2013
Sorry to keep annoying you, but the commit's author name is still
blackwolf12333.
There are also some of trailing whitespaces, i've put inline comments for them.
2013/3/27 Peter Maatman <blackwolf12333 at gmail.com>:
> From: blackwolf12333 <blackwolf12333 at gmail.com>
>
> This handler will do exactly the same as the SIGSEGV handler
> but now for the SIGABRT signal.
> ---
> src/compositor.c | 35 +++++++++++++++++++++--------------
> 1 file changed, 21 insertions(+), 14 deletions(-)
>
> diff --git a/src/compositor.c b/src/compositor.c
> index a2860fd..5d4c9b2 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -3221,26 +3221,25 @@ print_backtrace(void)
> #endif
>
> static void
> -on_segv_signal(int s, siginfo_t *siginfo, void *context)
> +on_caught_signal(int s, siginfo_t *siginfo, void *context)
> {
> - /* This SIGSEGV handler will do a best-effort backtrace, and
> + /* This signal handler will do a best-effort backtrace, and
> * then call the backend restore function, which will switch
> * back to the vt we launched from or ungrab X etc and then
> * raise SIGTRAP. If we run weston under gdb from X or a
> - * different vt, and tell gdb "handle SIGSEGV nostop", this
> + * different vt, and tell gdb "handle *s* nostop", this
> * will allow weston to switch back to gdb on crash and then
> - * gdb will catch the crash with SIGTRAP. */
> -
> - weston_log("caught segv\n");
> -
> + * gdb will catch the crash with SIGTRAP.*/
> +
> + weston_log("caught signal: %d\n", s);
> +
> print_backtrace();
> -
> +
Careful here, you have some trailing tabs. git log will show them,
remove them, please.
> segv_compositor->restore(segv_compositor);
>
> raise(SIGTRAP);
> }
>
> -
> static void *
> load_module(const char *name, const char *entrypoint)
> {
> @@ -3393,6 +3392,18 @@ usage(int error_code)
> exit(error_code);
> }
>
> +static void
> +catch_signals()
> +{
> + struct sigaction action;
> +
Here too.
> + action.sa_flags = SA_SIGINFO | SA_RESETHAND;
> + action.sa_sigaction = on_caught_signal;
> + sigemptyset(&action.sa_mask);
> + sigaction(SIGSEGV, &action, NULL);
> + sigaction(SIGABRT, &action, NULL);
> +}
> +
> int main(int argc, char *argv[])
> {
> int ret = EXIT_SUCCESS;
> @@ -3400,7 +3411,6 @@ int main(int argc, char *argv[])
> struct weston_compositor *ec;
> struct wl_event_source *signals[4];
> struct wl_event_loop *loop;
> - struct sigaction segv_action;
> struct weston_compositor
> *(*backend_init)(struct wl_display *display,
> int *argc, char *argv[], const char *config_file);
> @@ -3491,10 +3501,7 @@ int main(int argc, char *argv[])
> exit(EXIT_FAILURE);
> }
>
> - segv_action.sa_flags = SA_SIGINFO | SA_RESETHAND;
> - segv_action.sa_sigaction = on_segv_signal;
> - sigemptyset(&segv_action.sa_mask);
> - sigaction(SIGSEGV, &segv_action, NULL);
> + catch_signals();
> segv_compositor = ec;
>
> ec->option_idle_time = idle_time;
> --
> 1.8.2
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list