comparison src/dnsbl.cpp @ 22:c21b888cc175 stable-2-2

fix restart code, add ifdef for linux pid issues
author carl
date Sat, 01 May 2004 07:44:51 -0700
parents 041ea016b684
children 06de5ab6a232
comparison
equal deleted inserted replaced
21:19f11ae628df 22:c21b888cc175
1115 // write the pid 1115 // write the pid
1116 const char *pidpath = "/var/run/dnsbl.pid"; 1116 const char *pidpath = "/var/run/dnsbl.pid";
1117 unlink(pidpath); 1117 unlink(pidpath);
1118 FILE *f = fopen(pidpath, "w"); 1118 FILE *f = fopen(pidpath, "w");
1119 if (f) { 1119 if (f) {
1120 #ifdef linux
1121 // from a comment in the DCC source code:
1122 // Linux threads are broken. Signals given the
1123 // original process are delivered to only the
1124 // thread that happens to have that PID. The
1125 // sendmail libmilter thread that needs to hear
1126 // SIGINT and other signals does not, and that breaks
1127 // scripts that need to stop milters.
1128 // However, signaling the process group works.
1120 fprintf(f, "-%d\n", (u_int)getpgrp()); 1129 fprintf(f, "-%d\n", (u_int)getpgrp());
1130 #else
1131 fprintf(f, "%d\n", (u_int)getpid());
1132 #endif
1121 fclose(f); 1133 fclose(f);
1122 } 1134 }
1123 1135
1124 time_t starting = time(NULL); 1136 time_t starting = time(NULL);
1125 int rc = smfi_main(); 1137 int rc = smfi_main();
1126 if (time(NULL) > starting+5*60) { 1138 if ((rc != MI_SUCCESS) && (time(NULL) > starting+5*60)) {
1127 my_syslog("trying to restart after smfi_main()"); 1139 my_syslog("trying to restart after smfi_main()");
1128 loader_run = false; // eventually the config loader thread will terminate 1140 loader_run = false; // eventually the config loader thread will terminate
1129 execvp(argv[0], argv); 1141 execvp(argv[0], argv);
1130 } 1142 }
1131 exit((rc == MI_SUCCESS) ? 0 : EX_UNAVAILABLE); 1143 exit((rc == MI_SUCCESS) ? 0 : EX_UNAVAILABLE);