[23/28] make the mainloop immune against the signals

Message ID 1308256197-29155-23-git-send-email-daniel.lezcano@linaro.org
State Accepted
Headers show

Commit Message

Daniel Lezcano June 16, 2011, 8:29 p.m.
... needed at least for gdb ...

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 powerdebug.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

Patch

diff --git a/powerdebug.c b/powerdebug.c
index 7d89a7b..8e7e78e 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -288,10 +288,17 @@  int mainloop(struct powerdebug_options *options,
 		tval.tv_sec = options->ticktime;
 		tval.tv_usec = (options->ticktime - tval.tv_sec) * 1000000;
 
+	again:
 		key = select(1, &readfds, NULL, NULL, &tval);
 		if (!key)
 			continue;
 
+		if (key < 0) {
+			if (errno == EINTR)
+				goto again;
+			break;
+		}
+
 		if (keystroke_callback(&enter_hit, &findparent_ncurses,
 				       clkname_str, &refreshwin, options))
 			break;