void catch_sig_term(int sig)
{
+ fprintf(stderr, "inside catch_sig_term");
gotsigterm = 1;
}
addr);
continue;
}
+ if(gotsigterm && listaddr && archivefilename) {
+ /* we got SIGTERM, so save the addresses and bail */
+ log_error(LOG_ARGS, "TERM signal recieved, "
+ "shutting down.");
+ index = mybasename(archivefilename);
+ return requeuemail(listdir, index, addrs, i);
+ }
if(from) {
res = send_mail(sockfd, from, addr, replyto,
mailmap, mailsize, listdir, NULL,
hdrs, hdrslen, body, bodylen);
myfree(bounceaddr);
}
- if((res || gotsigterm) && listaddr && archivefilename) {
- /* we failed or got a SIGTERM, so save the addresses
- * and bail */
+ if(res && listaddr && archivefilename) {
+ /* we failed, so save the addresses and bail */
index = mybasename(archivefilename);
return requeuemail(listdir, index, addrs, i);
}
/* install signal handler for SIGTERM */
sigact.sa_handler = catch_sig_term;
- sigact.sa_flags = 0;
sigemptyset(&sigact.sa_mask);
+ sigact.sa_flags = 0;
if(sigaction(SIGTERM, &sigact, NULL) < 0)
log_error(LOG_ARGS, "Could not install SIGTERM handler!");