Mercurial > hg > mlmmj
changeset 493:52be16e46e2b
correct signal handling
author | mmj |
---|---|
date | Wed, 04 May 2005 19:16:29 +1000 |
parents | 9bb06d43c025 |
children | af9b8c5b81ef |
files | src/mlmmj-send.c |
diffstat | 1 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/mlmmj-send.c Tue May 03 17:50:31 2005 +1000 +++ b/src/mlmmj-send.c Wed May 04 19:16:29 2005 +1000 @@ -69,6 +69,7 @@ void catch_sig_term(int sig) { + fprintf(stderr, "inside catch_sig_term"); gotsigterm = 1; } @@ -573,6 +574,13 @@ 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, @@ -585,9 +593,8 @@ 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); } @@ -656,8 +663,8 @@ /* install signal handler for SIGTERM */ sigact.sa_handler = catch_sig_term; + sigemptyset(&sigact.sa_mask); sigact.sa_flags = 0; - sigemptyset(&sigact.sa_mask); if(sigaction(SIGTERM, &sigact, NULL) < 0) log_error(LOG_ARGS, "Could not install SIGTERM handler!");