Signed-off-by: Francesco Giudici <fgiudici@xxxxxxxxxx> --- src/virt-viewer-app.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c index 06e237b..6712e6a 100644 --- a/src/virt-viewer-app.c +++ b/src/virt-viewer-app.c @@ -1757,7 +1757,6 @@ static gboolean opt_fullscreen = FALSE; static gboolean opt_kiosk = FALSE; static gboolean opt_kiosk_quit = FALSE; -#ifndef G_OS_WIN32 static int sigint_pipe[2]; static void @@ -1773,6 +1772,19 @@ sigint_handler(int signum) errno = savedErrno; } +#ifdef G_OS_WIN32 +static void +register_sigint_handler() +{ + if (_pipe(sigint_pipe, 1, 0) == -1) + goto err; + + signal(SIGINT, sigint_handler); + +err: + g_debug("Cannot register SIGINT handler\n"); +} +#else static void register_sigint_handler() { @@ -1802,6 +1814,7 @@ register_sigint_handler() err: g_debug("Cannot register SIGINT handler\n"); } +#endif static gboolean sigint_cb(GIOChannel *source, @@ -1823,7 +1836,6 @@ sigint_cb(GIOChannel *source, g_io_channel_read_chars (source, &sbuf, 1, NULL, NULL); return TRUE; } -#endif static void title_maybe_changed(VirtViewerApp *self, GParamSpec* pspec G_GNUC_UNUSED, gpointer user_data G_GNUC_UNUSED) @@ -1835,19 +1847,19 @@ static void virt_viewer_app_init(VirtViewerApp *self) { GError *error = NULL; -#ifndef G_OS_WIN32 GIOChannel *sigint_channel = NULL; -#endif self->priv = virt_viewer_app_get_instance_private(self); gtk_window_set_default_icon_name("virt-viewer"); -#ifndef G_OS_WIN32 register_sigint_handler(); +#ifdef G_OS_WIN32 + sigint_channel = g_io_channel_win32_new_fd(sigint_pipe[0]); +#else sigint_channel = g_io_channel_unix_new(sigint_pipe[0]); - g_io_add_watch(sigint_channel, G_IO_IN, sigint_cb, self); #endif + g_io_add_watch(sigint_channel, G_IO_IN, sigint_cb, self); self->priv->displays = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_object_unref); self->priv->config = g_key_file_new(); -- 2.21.0 _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list