Index: ossp-pkg/lmtp2nntp/lmtp2nntp.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/lmtp2nntp.c,v rcsdiff -q -kk '-r1.82' '-r1.83' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/lmtp2nntp.c,v' 2>/dev/null --- lmtp2nntp.c 2001/10/12 07:14:28 1.82 +++ lmtp2nntp.c 2001/10/12 07:43:31 1.83 @@ -341,16 +341,24 @@ return; } if (ctx != NULL) { - if ((sig == SIGHUP) || (sig == SIGINT) || (sig == SIGQUIT)) - log1(ctx, NOTICE, "caught signal %d - exit - no more logging", sig); - 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); - l2_stream_flush(ctx->l2); - return; - } else - log1(ctx, PANIC, "CAUGHT SIGNAL %d - EXIT - NO MORE LOGGING", sig); + switch (sig) { + case 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; + case SIGUSR1: + log1(ctx, NOTICE, "caught signal %d - flush logging buffer", sig); + l2_stream_flush(ctx->l2); + return; + case SIGHUP: + case SIGINT: + case SIGQUIT: + log1(ctx, NOTICE, "caught signal %d - exit - no more logging", sig); + break; + default: + log1(ctx, PANIC, "CAUGHT SIGNAL %d - EXIT - NO MORE LOGGING", sig); + } l2_stream_destroy(ctx->l2); } exit(ERR_EXECUTION); @@ -923,7 +931,7 @@ signal(SIGSEGV, (void(*)())catchsignal); signal(SIGSYS, (void(*)())catchsignal); signal(SIGTERM, (void(*)())catchsignal); - signal(SIGUSR1, SIG_IGN ); + signal(SIGUSR1, (void(*)())catchsignal); signal(SIGUSR2, SIG_IGN ); /* loop for LMTP protocol with support for alternate io through daemon */ @@ -968,7 +976,7 @@ pid = getpid(); if (ctx->option_daemon) { daemonize(); - log1(ctx, NOTICE, "daemonized, previous pid[%d]", pid); l2_stream_flush(ctx->l2); + log1(ctx, NOTICE, "daemonized, previous pid[%d]", pid); } if (ctx->option_pidfile != NULL) { if ((fd = fopen(ctx->option_pidfile, "w+")) == NULL) @@ -1027,27 +1035,27 @@ sa_addr_a2u(ctx->saaIO, &cpA); log1(ctx, TRACE, "connection from %s accepted due to ACL", cpA); free(cpA); - l2_stream_flush(ctx->l2); } else { char *cpA; sa_addr_a2u(ctx->saaIO, &cpA); log1(ctx, ERROR, "connection from %s refused due to ACL", cpA); free(cpA); - l2_stream_flush(ctx->l2); sa_destroy(ctx->saIO); sa_addr_destroy(ctx->saaIO); continue; } - l2_stream_flush(ctx->l2); /* must flush before fork() */ + /* logging buffer must be empty before fork otherwise content is + * duplicated and written twice on next flush */ + l2_stream_flush(ctx->l2); pid = fork(); if (pid == -1) { - log0(ctx, ERROR, "daemon cannot spawn child %m"); l2_stream_flush(ctx->l2); + log0(ctx, ERROR, "daemon cannot spawn child %m"); continue; } if (pid != 0) { - log1(ctx, INFO, "daemon forked process, new child pid[%d]", pid); l2_stream_flush(ctx->l2); + log1(ctx, INFO, "daemon forked process, new child pid[%d]", pid); sa_destroy(ctx->saIO); sa_addr_destroy(ctx->saaIO); continue; Index: ossp-pkg/lmtp2nntp/lmtp2nntp.pod RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp.pod,v rcsdiff -q -kk '-r1.27' '-r1.28' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp.pod,v' 2>/dev/null --- lmtp2nntp.pod 2001/10/09 20:12:30 1.27 +++ lmtp2nntp.pod 2001/10/12 07:43:31 1.28 @@ -210,6 +210,10 @@ =back +=head1 SIGNALS + +Sending a USR1 signal to the program will flush the logging buffer. + =head1 DIAGNOSTICS If invoked it returns 0 on successful execution (not neccessarily