OSSP CVS Repository

ossp - Check-in [1098]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1098
Date: 2001-Oct-08 12:28:42 (local)
2001-Oct-08 10:28:42 (UTC)
User:thl
Branch:
Comment: defeated zombies
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/lmtp2nntp.c      1.64 -> 1.65     13 inserted, 4 deleted
ossp-pkg/lmtp2nntp/test.sh      1.2 -> 1.3     3 inserted, 3 deleted

ossp-pkg/lmtp2nntp/lmtp2nntp.c 1.64 -> 1.65

--- lmtp2nntp.c  2001/10/04 16:07:16     1.64
+++ lmtp2nntp.c  2001/10/08 10:28:42     1.65
@@ -32,6 +32,8 @@
 #include <fcntl.h>
 #include <sys/utsname.h>
 #include <sys/time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 #include <signal.h>
 
 /* third party */
@@ -176,11 +178,11 @@
      */
     fprintf(stderr, 
             "USAGE: %s "
+            "[-a altio] "
             "[-b bindaddr[:port]] "
             "[-d deliverymode] "
             "[-g groupmode] "
             "[-h host[:port][,host[:port], ...]] "
-            "[-i inputbind] "
             "[-l level[:logfile]] "
             "[-m mailfrom] "
             "[-n nodename] "
@@ -271,9 +273,10 @@
 {
     va_list ap;
     static lmtp2nntp_t *ctx = NULL;
+    pid_t pid;
 
-    va_start(ap, sig);
     if(sig == 0) {
+        va_start(ap, sig);
         if ((ctx = va_arg(ap, lmtp2nntp_t *)) == NULL)
             exit(ERR_EXECUTION);
         log0(ctx, TRACE, "catching and logging signals now");
@@ -283,14 +286,19 @@
     if (ctx != NULL) {
         if ((sig == SIGHUP) || (sig == SIGINT) || (sig == SIGQUIT))
             log1(ctx, NOTICE, "caught signal %d - exit - no more logging", sig);
-        else
+        else if (sig == SIGCHLD) {
+            log1(ctx, NOTICE, "caught signal %d - wait for child", sig);
+            pid = wait(NULL);
+            log2(ctx, NOTICE, "caught signal %d - child [%ld] terminated", sig, (long)pid);
+            return;
+        } else
             log1(ctx, PANIC, "CAUGHT SIGNAL %d - EXIT - NO MORE LOGGING", sig);
         l2_stream_destroy(ctx->l2);
     }
-    va_end(ap);
     exit(ERR_EXECUTION);
 }
 
+
 int main(int argc, char **argv)
 {
     int           rc;
@@ -656,6 +664,7 @@
     }
 
     catchsignal(0, ctx);
+    signal(SIGCHLD, (void(*)())catchsignal);
     signal(SIGHUP,  (void(*)())catchsignal);
     signal(SIGINT,  (void(*)())catchsignal);
     signal(SIGQUIT, (void(*)())catchsignal);


ossp-pkg/lmtp2nntp/test.sh 1.2 -> 1.3

--- test.sh      2001/09/13 12:50:46     1.2
+++ test.sh      2001/10/08 10:28:42     1.3
@@ -16,10 +16,10 @@
 Message-Id: <200108141251.f7ECpmn74812@dev.de.cw.net>
 From: Thomas Lotterer <Thomas.Lotterer@example.com>
 Received: from cw.example.com (cw.example.com [10.1.1.32])
-    by gateway.example.com (8.9.2/8.9.2/$Revision: 1.2 $) with SMTP id NAA08840
+    by gateway.example.com (8.9.2/8.9.2/$Revision: 1.3 $) with SMTP id NAA08840
     for <thomas.lotterer@gateway.example.com>; Mon, 2 Apr 2001 13:20:25 +0200 (MET DST)
 Received: from history (history.example.org [195.143.102.41])
-    by cw.example.com (8.11.0/8.11.0/$Revision: 1.2 $) with ESMTP id f32BKPb12235
+    by cw.example.com (8.11.0/8.11.0/$Revision: 1.3 $) with ESMTP id f32BKPb12235
     for <thomas.lotterer@example.com>; Mon, 2 Apr 2001 13:20:25 +0200
 Received: from example.org (littlemua.example.org [195.143.103.160])
         by history (8.8.8/8.8.8) with ESMTP id LAA12678;
@@ -107,7 +107,7 @@
 prolog
 newmsg
 ./lmtp2nntp -? >${STDOUT} 2>${STDERR}
-RC=`cat ${STDERR} | egrep -- '-b.*-d.*-g.*-h.*-m.*-n.*-s.*-l.*-v.*-w.*newsgroup' | wc -l`
+RC=`cat ${STDERR} | egrep -- '-a.*-b.*-d.*-g.*-h.*-l.*-m.*-n.*-s.*-v.*-w.*newsgroup' | wc -l`
 if [ ${RC} -ne 1 -o -s ${STDOUT} ]; then
     echo "NO (got ${RC})"
     exit 1;

CVSTrac 2.0.1