[Pinfo-devel] r309 - pinfo/trunk/src
Bas Zoetekouw
bas at alioth.debian.org
Sun Sep 19 11:36:29 UTC 2010
Author: bas
Date: 2010-09-19 11:36:28 +0000 (Sun, 19 Sep 2010)
New Revision: 309
Modified:
pinfo/trunk/src/manual.c
pinfo/trunk/src/signal_handler.c
pinfo/trunk/src/utils.c
Log:
Fix getch() handling after suspend/resume.
Thanks to Scott McDermott for the patch.
Modified: pinfo/trunk/src/manual.c
===================================================================
--- pinfo/trunk/src/manual.c 2006-08-15 15:15:07 UTC (rev 308)
+++ pinfo/trunk/src/manual.c 2010-09-19 11:36:28 UTC (rev 309)
@@ -967,7 +967,7 @@
key = pinfo_getch();
}
/************************ keyboard handling **********************************/
- if (key != 0)
+ if (key > 0)
{
if ((key == keys.print_1) ||
(key == keys.print_2))
Modified: pinfo/trunk/src/signal_handler.c
===================================================================
--- pinfo/trunk/src/signal_handler.c 2006-08-15 15:15:07 UTC (rev 308)
+++ pinfo/trunk/src/signal_handler.c 2010-09-19 11:36:28 UTC (rev 309)
@@ -44,6 +44,29 @@
}
void
+handle_suspend(int signum)
+{
+ if (!isendwin()) {
+ curs_set(1);
+ endwin();
+ }
+ fprintf(stderr, "\n");
+ signal(SIGTSTP, handle_suspend);
+ kill(0, SIGSTOP);
+}
+
+void
+handle_resume(int signum)
+{
+ if (isendwin()) {
+ refresh();
+ curs_set(0);
+ }
+ ungetch(keys.refresh_1);
+ signal(SIGCONT, handle_resume);
+}
+
+void
signal_handler()
{
sigset_t sigs;
@@ -52,6 +75,8 @@
signal(SIGTERM, handle_crash); /* handle soft kill */
signal(SIGSEGV, handle_crash); /* handle seg. fault */
signal(SIGHUP, handle_crash); /* handle hup signal */
+ signal(SIGTSTP, handle_suspend);/* handle terminal suspend */
+ signal(SIGCONT, handle_resume); /* handle back from suspend */
#ifdef SIGWINCH
signal(SIGWINCH, handle_window_resize);
#endif
Modified: pinfo/trunk/src/utils.c
===================================================================
--- pinfo/trunk/src/utils.c 2006-08-15 15:15:07 UTC (rev 308)
+++ pinfo/trunk/src/utils.c 2010-09-19 11:36:28 UTC (rev 309)
@@ -376,10 +376,15 @@
void
waitforgetch()
{
+ int ret;
+
fd_set rdfs;
FD_ZERO(&rdfs);
FD_SET(0, &rdfs);
- select(1, &rdfs, NULL, NULL, NULL);
+
+ /* we might get interrupted by e.g. SIGTSTP/SIGCONT */
+ do ret = select(1, &rdfs, NULL, NULL, NULL);
+ while (ret == -1 && errno == EINTR);
}
/* returns 0 on success, 1 on error */
More information about the Pinfo-devel
mailing list