aboutsummaryrefslogtreecommitdiffstats
path: root/lcd4linux.c
diff options
context:
space:
mode:
authorreinelt <>2000-08-09 09:50:29 +0000
committerreinelt <>2000-08-09 09:50:29 +0000
commit58deee6b03e396b6cba5e4e888940419c240866b (patch)
treeddf01503c9b524efbe08b2887ab9b9f0bed1dc55 /lcd4linux.c
parenta7f2de2a1d1fb7b5c8b3ba277ea66f01e692dd18 (diff)
downloadlcd4linux-58deee6b03e396b6cba5e4e888940419c240866b.tar.gz
[lcd4linux @ 2000-08-09 09:50:29 by reinelt]
opened 0.98 development removed driver-specific signal-handlers added 'quit'-function to driver structure added global signal-handler
Diffstat (limited to 'lcd4linux.c')
-rw-r--r--lcd4linux.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/lcd4linux.c b/lcd4linux.c
index 0e82382..0d49202 100644
--- a/lcd4linux.c
+++ b/lcd4linux.c
@@ -1,4 +1,4 @@
-/* $Id: lcd4linux.c,v 1.23 2000/04/17 05:14:27 reinelt Exp $
+/* $Id: lcd4linux.c,v 1.24 2000/08/09 09:50:29 reinelt Exp $
*
* LCD4Linux
*
@@ -20,6 +20,13 @@
*
*
* $Log: lcd4linux.c,v $
+ * Revision 1.24 2000/08/09 09:50:29 reinelt
+ *
+ * opened 0.98 development
+ * removed driver-specific signal-handlers
+ * added 'quit'-function to driver structure
+ * added global signal-handler
+ *
* Revision 1.23 2000/04/17 05:14:27 reinelt
*
* added README.44780
@@ -136,6 +143,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
+#include <signal.h>
#include "cfg.h"
#include "debug.h"
@@ -145,6 +153,7 @@
char *release="LCD4Linux " VERSION " (c) 2000 Michael Reinelt <reinelt@eunet.at>";
char *output=NULL;
+int got_signal=0;
int debugging=0;
int tick, tack;
@@ -157,7 +166,7 @@ static void usage(void)
printf (" lcd4linux [-c key=value] [-f config-file] [-o output-file] [-q] [-v]\n");
}
-int lcd_hello (void)
+int hello (void)
{
int i, x, y, flag;
char *line1[] = { "* LCD4Linux V" VERSION " *",
@@ -209,6 +218,12 @@ void calibrate (void)
printf (" Delay=%ld\n", max);
}
+void handler (int signal)
+{
+ debug ("got signal %d\n", signal);
+ got_signal=signal;
+}
+
int main (int argc, char *argv[])
{
char *cfg="/etc/lcd4linux.conf";
@@ -279,13 +294,18 @@ int main (int argc, char *argv[])
exit (1);
}
+ signal(SIGHUP, handler);
+ signal(SIGINT, handler);
+ signal(SIGQUIT, handler);
+ signal(SIGTERM, handler);
+
tick=atoi(cfg_get("tick")?:"100");
tack=atoi(cfg_get("tack")?:"500");
process_init();
lcd_clear();
- if (!quiet && lcd_hello()) {
+ if (!quiet && hello()) {
sleep (3);
lcd_clear();
}
@@ -293,10 +313,21 @@ int main (int argc, char *argv[])
debug ("starting main loop\n");
smooth=0;
- while (1) {
+ while (got_signal==0) {
process (smooth);
smooth+=tick;
if (smooth>tack) smooth=0;
usleep(tick*1000);
}
+
+ debug ("leaving main loop\n");
+
+ lcd_clear();
+ if (!quiet) hello();
+ lcd_quit();
+
+ if (got_signal==SIGHUP) {
+ debug ("restarting\n");
+ }
+ exit (0);
}