[gnome-battery-bench] gbb test: clean up on Control-C
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-battery-bench] gbb test: clean up on Control-C
- Date: Mon, 5 Jan 2015 13:01:35 +0000 (UTC)
commit 8cb408a950c10492758cb55247ea917845dca80e
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Fri Jan 2 16:17:45 2015 -0500
gbb test: clean up on Control-C
Clean up cleanly (restoring backlight brightness, running epilogue)
on SIGINT.
src/commandline.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/src/commandline.c b/src/commandline.c
index 812e100..54133c1 100644
--- a/src/commandline.c
+++ b/src/commandline.c
@@ -13,6 +13,7 @@
#include <X11/Xlib.h>
#include <glib.h>
+#include <glib-unix.h>
#include <gio/gio.h>
#include "evdev-player.h"
@@ -301,6 +302,14 @@ fail:
die("Can't parse duration string '%s'", duration);
}
+static gboolean
+on_sigint(gpointer data)
+{
+ GbbTestRunner *runner = data;
+ gbb_test_runner_stop(runner);
+ return TRUE;
+}
+
static int
test(int argc, char **argv)
{
@@ -342,6 +351,8 @@ test(int argc, char **argv)
G_CALLBACK(test_on_player_ready), runner);
}
+ g_unix_signal_add(SIGINT, on_sigint, runner);
+
GMainLoop *loop = g_main_loop_new (NULL, FALSE);
g_signal_connect(runner, "phase-changed",
G_CALLBACK(on_runner_phase_changed), loop);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]