Index: ossp-pkg/lmtp2nntp/lmtp2nntp.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/lmtp2nntp.c,v rcsdiff -q -kk '-r1.64' '-r1.65' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/lmtp2nntp.c,v' 2>/dev/null --- 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 #include #include +#include +#include #include /* 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); Index: ossp-pkg/lmtp2nntp/test.sh RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/test.sh,v rcsdiff -q -kk '-r1.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/test.sh,v' 2>/dev/null --- test.sh 2001/09/13 12:50:46 1.2 +++ test.sh 2001/10/08 10:28:42 1.3 @@ -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;