The active = 0|1 thingy is essential for a networking application -> re-activated
authorMarkus Bröker <mbroeker@largo.dyndns.tv>
Sat, 13 Dec 2008 15:40:46 +0100
changeset 16 33245bf7873a
parent 15 f19c1f9b4cd3
child 17 9a32b5242320
The active = 0|1 thingy is essential for a networking application -> re-activated committer: Markus Bröker <mbroeker@largo.homelinux.org>
src/main.c
src/parse.c
--- a/src/main.c
+++ b/src/main.c
@@ -23,9 +23,12 @@
 #define LOCALE_PATH "/var/lib/nobody/data/locale"
 #endif
 
+short active = 1;               /* needed for a safe shutdown */
+
 void sigproc ()
 {
     signal (SIGTERM, sigproc);
+    active = 0;
 }
 
 int main (int argc, char **argv)
@@ -91,7 +94,11 @@
 
     while (!feof (message.stream)) {
         *buf = '\0';
-        fgets (buf, 512, message.stream);
+
+        if (active)             /* SIGPROC */
+            fgets (buf, 512, message.stream);
+        else
+            break;
 
         if ((command = irc_parsemessage (buf, &message))) {
             printf ("%10s %s %s\n", command, message.channel, message.line);
--- a/src/parse.c
+++ b/src/parse.c
@@ -61,6 +61,7 @@
     "!debug:    prints some debug infos\r\n",
     "!vaccuum:  reorganizes the database\r\n",
     "!logout:   Protected logout function\r\n",
+    NULL,
 };
 
 const