summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2004-07-10 19:59:06 (UTC)
committer Michael Krelin <hacker@klever.net>2004-07-10 19:59:06 (UTC)
commit4f8a6f291a231410a03c438bc9d63a7beb861e7b (patch) (unidiff)
tree790352f42d045e23e9bbb6ae3a210d4faeae8244
parent9148dac885c0325636c2d33715ba248371706d0d (diff)
downloaddudki-4f8a6f291a231410a03c438bc9d63a7beb861e7b.zip
dudki-4f8a6f291a231410a03c438bc9d63a7beb861e7b.tar.gz
dudki-4f8a6f291a231410a03c438bc9d63a7beb861e7b.tar.bz2
fixed signal handling, so that dudki can be HUP-ped more than once.0.0
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/dudki.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/dudki.cc b/src/dudki.cc
index 3c50e56..b769109 100644
--- a/src/dudki.cc
+++ b/src/dudki.cc
@@ -215,30 +215,35 @@ int main(int argc,char **argv) {
215 case op_work: 215 case op_work:
216 { 216 {
217 if(config.daemonize) { 217 if(config.daemonize) {
218 pid_t pf = fork(); 218 pid_t pf = fork();
219 if(pf<0) 219 if(pf<0)
220 throw runtime_error(string(__PRETTY_FUNCTION__)+": failed to fork()"); 220 throw runtime_error(string(__PRETTY_FUNCTION__)+": failed to fork()");
221 if(pf) { 221 if(pf) {
222 _exit(0); 222 _exit(0);
223 } 223 }
224 } 224 }
225 pid_file pidfile; 225 pid_file pidfile;
226 pidfile.set(config.pidfile); 226 pidfile.set(config.pidfile);
227 signal(SIGINT,lethal_signal_handler); 227 signal(SIGINT,lethal_signal_handler);
228 signal(SIGABRT,lethal_signal_handler); 228 signal(SIGABRT,lethal_signal_handler);
229 signal(SIGTERM,lethal_signal_handler); 229 signal(SIGTERM,lethal_signal_handler);
230 signal(SIGHUP,sighup_handler); 230 signal(SIGHUP,sighup_handler);
231 sigset_t sset;
232 sigemptyset(&sset);
233 sigaddset(&sset,SIGINT); sigaddset(&sset,SIGABRT);
234 sigaddset(&sset,SIGTERM); sigaddset(&sset,SIGHUP);
235 sigprocmask(SIG_UNBLOCK,&sset,NULL);
231 while(!finishing) { 236 while(!finishing) {
232 check_herd(config); 237 check_herd(config);
233 sleep(config.check_interval); 238 sleep(config.check_interval);
234 } 239 }
235 } 240 }
236 break; 241 break;
237 default: 242 default:
238 throw runtime_error(string(__PRETTY_FUNCTION__)+": internal error"); 243 throw runtime_error(string(__PRETTY_FUNCTION__)+": internal error");
239 } 244 }
240 }catch(exception& e) { 245 }catch(exception& e) {
241 cerr << "Oops: " << e.what() << endl; 246 cerr << "Oops: " << e.what() << endl;
242 return 1; 247 return 1;
243 } 248 }
244} 249}