OSSP CVS Repository

ossp - Difference in ossp-pkg/lmtp2nntp/lmtp2nntp.c versions 1.64 and 1.65
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

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);

CVSTrac 2.0.1