src/main.c
changeset 16 33245bf7873a
parent 15 f19c1f9b4cd3
child 17 9a32b5242320
--- 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);