* [Qemu-devel] [PATCH v2] curses: fixup SIGWINCH handler mess
@ 2013-11-13 9:23 Gerd Hoffmann
2013-11-13 14:15 ` Laszlo Ersek
0 siblings, 1 reply; 3+ messages in thread
From: Gerd Hoffmann @ 2013-11-13 9:23 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Anthony Liguori
Don't run code in the signal handler, only set a flag.
Use sigaction(2) to avoid non-portable signal(2) semantics.
Make #ifdefs less messy.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/curses.c | 44 ++++++++++++++++++++++++++++----------------
1 file changed, 28 insertions(+), 16 deletions(-)
diff --git a/ui/curses.c b/ui/curses.c
index 289a955..dbc3d5e 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -106,9 +106,9 @@ static void curses_resize(DisplayChangeListener *dcl,
curses_calc_pad();
}
-#ifndef _WIN32
-#if defined(SIGWINCH) && defined(KEY_RESIZE)
-static void curses_winch_handler(int signum)
+#if !defined(_WIN32) && defined(SIGWINCH) && defined(KEY_RESIZE)
+static volatile sig_atomic_t got_sigwinch;
+static void curses_winch_check(void)
{
struct winsize {
unsigned short ws_row;
@@ -117,18 +117,34 @@ static void curses_winch_handler(int signum)
unsigned short ws_ypixel; /* unused */
} ws;
- /* terminal size changed */
- if (ioctl(1, TIOCGWINSZ, &ws) == -1)
+ if (!got_sigwinch) {
+ return;
+ }
+ got_sigwinch = false;
+
+ if (ioctl(1, TIOCGWINSZ, &ws) == -1) {
return;
+ }
resize_term(ws.ws_row, ws.ws_col);
- curses_calc_pad();
invalidate = 1;
+}
- /* some systems require this */
- signal(SIGWINCH, curses_winch_handler);
+static void curses_winch_handler(int signum)
+{
+ got_sigwinch = true;
}
-#endif
+
+static void curses_winch_init(void)
+{
+ struct sigaction old, winch = {
+ .sa_handler = curses_winch_handler,
+ };
+ sigaction(SIGWINCH, &winch, &old);
+}
+#else
+static void curses_winch_check(void) {}
+static void curses_winch_init(void) {}
#endif
static void curses_cursor_position(DisplayChangeListener *dcl,
@@ -163,6 +179,8 @@ static void curses_refresh(DisplayChangeListener *dcl)
{
int chr, nextchr, keysym, keycode, keycode_alt;
+ curses_winch_check();
+
if (invalidate) {
clear();
refresh();
@@ -349,13 +367,7 @@ void curses_display_init(DisplayState *ds, int full_screen)
curses_keyboard_setup();
atexit(curses_atexit);
-#ifndef _WIN32
-#if defined(SIGWINCH) && defined(KEY_RESIZE)
- /* some curses implementations provide a handler, but we
- * want to be sure this is handled regardless of the library */
- signal(SIGWINCH, curses_winch_handler);
-#endif
-#endif
+ curses_winch_init();
dcl = (DisplayChangeListener *) g_malloc0(sizeof(DisplayChangeListener));
dcl->ops = &dcl_ops;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* [Qemu-devel] [PATCH 0/6] usb: remote wakeup improvements
@ 2013-11-20 14:35 Gerd Hoffmann
2013-11-20 14:35 ` [Qemu-devel] [PATCH v2] curses: fixup SIGWINCH handler mess Gerd Hoffmann
0 siblings, 1 reply; 3+ messages in thread
From: Gerd Hoffmann @ 2013-11-20 14:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Hi,
USB patch series from the ReduceWakeupRate department.
Patch #1 implements remote wakeup support to the ehci emulation.
Patch #2 reverts a workaround for lacking ehci remote wakeup
support in the highspeed version of the usb tablet.
Patches #3 + #4 are small preparations for #5.
Patch #5 adds support for microsoft os descriptors.
Patch #6 puts them into use to set registry keys for
the usb tablet.
This series brings windows guests on par with what we have
in Linux for quite a while already: Remote wakeup is used
by default, without manual configuration.
Gerd Hoffmann (6):
ehci: implement port wakeup
Revert "usb-tablet: Don't claim wakeup capability for USB-2 version"
usb: add vendor request defines
usb: move usb_{hi,lo} helpers to header file.
usb: add support for microsoft os descriptors
usb-tablet: add microsoft os descriptor support
hw/usb/Makefile.objs | 2 +-
hw/usb/desc-msos.c | 234 +++++++++++++++++++++++++++++++++++++++++++++++++++
hw/usb/desc.c | 22 ++---
hw/usb/desc.h | 20 +++++
hw/usb/dev-hid.c | 10 ++-
hw/usb/hcd-ehci.c | 18 +++-
include/hw/usb.h | 18 +++-
trace-events | 4 +
8 files changed, 309 insertions(+), 19 deletions(-)
create mode 100644 hw/usb/desc-msos.c
--
1.8.3.1
^ permalink raw reply [flat|nested] 3+ messages in thread* [Qemu-devel] [PATCH v2] curses: fixup SIGWINCH handler mess
2013-11-20 14:35 [Qemu-devel] [PATCH 0/6] usb: remote wakeup improvements Gerd Hoffmann
@ 2013-11-20 14:35 ` Gerd Hoffmann
0 siblings, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2013-11-20 14:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Anthony Liguori
Don't run code in the signal handler, only set a flag.
Use sigaction(2) to avoid non-portable signal(2) semantics.
Make #ifdefs less messy.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/curses.c | 44 ++++++++++++++++++++++++++++----------------
1 file changed, 28 insertions(+), 16 deletions(-)
diff --git a/ui/curses.c b/ui/curses.c
index 289a955..dbc3d5e 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -106,9 +106,9 @@ static void curses_resize(DisplayChangeListener *dcl,
curses_calc_pad();
}
-#ifndef _WIN32
-#if defined(SIGWINCH) && defined(KEY_RESIZE)
-static void curses_winch_handler(int signum)
+#if !defined(_WIN32) && defined(SIGWINCH) && defined(KEY_RESIZE)
+static volatile sig_atomic_t got_sigwinch;
+static void curses_winch_check(void)
{
struct winsize {
unsigned short ws_row;
@@ -117,18 +117,34 @@ static void curses_winch_handler(int signum)
unsigned short ws_ypixel; /* unused */
} ws;
- /* terminal size changed */
- if (ioctl(1, TIOCGWINSZ, &ws) == -1)
+ if (!got_sigwinch) {
+ return;
+ }
+ got_sigwinch = false;
+
+ if (ioctl(1, TIOCGWINSZ, &ws) == -1) {
return;
+ }
resize_term(ws.ws_row, ws.ws_col);
- curses_calc_pad();
invalidate = 1;
+}
- /* some systems require this */
- signal(SIGWINCH, curses_winch_handler);
+static void curses_winch_handler(int signum)
+{
+ got_sigwinch = true;
}
-#endif
+
+static void curses_winch_init(void)
+{
+ struct sigaction old, winch = {
+ .sa_handler = curses_winch_handler,
+ };
+ sigaction(SIGWINCH, &winch, &old);
+}
+#else
+static void curses_winch_check(void) {}
+static void curses_winch_init(void) {}
#endif
static void curses_cursor_position(DisplayChangeListener *dcl,
@@ -163,6 +179,8 @@ static void curses_refresh(DisplayChangeListener *dcl)
{
int chr, nextchr, keysym, keycode, keycode_alt;
+ curses_winch_check();
+
if (invalidate) {
clear();
refresh();
@@ -349,13 +367,7 @@ void curses_display_init(DisplayState *ds, int full_screen)
curses_keyboard_setup();
atexit(curses_atexit);
-#ifndef _WIN32
-#if defined(SIGWINCH) && defined(KEY_RESIZE)
- /* some curses implementations provide a handler, but we
- * want to be sure this is handled regardless of the library */
- signal(SIGWINCH, curses_winch_handler);
-#endif
-#endif
+ curses_winch_init();
dcl = (DisplayChangeListener *) g_malloc0(sizeof(DisplayChangeListener));
dcl->ops = &dcl_ops;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-11-20 14:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-13 9:23 [Qemu-devel] [PATCH v2] curses: fixup SIGWINCH handler mess Gerd Hoffmann
2013-11-13 14:15 ` Laszlo Ersek
-- strict thread matches above, loose matches on Subject: below --
2013-11-20 14:35 [Qemu-devel] [PATCH 0/6] usb: remote wakeup improvements Gerd Hoffmann
2013-11-20 14:35 ` [Qemu-devel] [PATCH v2] curses: fixup SIGWINCH handler mess Gerd Hoffmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.