> Block SIGWINCH, so it is delivered only via signalfd.
> Install a handler that uses NotifierList to tell
> interested parties about SIGWINCH delivery.
>
> Signed-off-by: Szymon Lukasz <[email protected]>
> Reviewed-by: Daniel P. Berrangé <[email protected]>
> Signed-off-by: Filip Hejsek <[email protected]>
> Message-ID: <[email protected]>
>
> diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h
> index 8c1241a2c11c..ff41346b0b5a 100644
> --- a/include/qemu/main-loop.h
> +++ b/include/qemu/main-loop.h
> @@ -449,4 +449,8 @@ typedef struct MainLoopPoll {
> void main_loop_poll_add_notifier(Notifier *notify);
> void main_loop_poll_remove_notifier(Notifier *notify);
>
> +#ifndef _WIN32
> +void sigwinch_add_notifier(Notifier *n);
Add a sigwinch_remove_notifier()
> +#endif
> +
> #endif
> diff --git a/ui/curses.c b/ui/curses.c
> index 4db32b6168d6..ced5fd1216b2 100644
> --- a/ui/curses.c
> +++ b/ui/curses.c
> @@ -33,6 +33,7 @@
> #include <iconv.h>
>
> #include "qapi/error.h"
> +#include "qemu/main-loop.h"
> #include "qemu/module.h"
> #include "ui/console.h"
> #include "ui/input.h"
> @@ -149,7 +150,7 @@ static void curses_resize(DisplayChangeListener *dcl,
> }
>
> #if !defined(_WIN32) && defined(SIGWINCH) && defined(KEY_RESIZE)
> -static volatile sig_atomic_t got_sigwinch;
> +static bool got_sigwinch;
> static void curses_winch_check(void)
> {
> struct winsize {
> @@ -172,17 +173,17 @@ static void curses_winch_check(void)
> invalidate = 1;
> }
>
> -static void curses_winch_handler(int signum)
> +static void curses_winch_handler(Notifier *n, void *data)
> {
> got_sigwinch = true;
> }
>
> static void curses_winch_init(void)
> {
> - struct sigaction old, winch = {
> - .sa_handler = curses_winch_handler,
> + static Notifier n = {
> + .notify = curses_winch_handler
> };
> - sigaction(SIGWINCH, &winch, &old);
> + sigwinch_add_notifier(&n);
> }
And remove the notifier in curses_cleanup()
--
Marc-André Lureau <[email protected]>