summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r--qpid/cpp/src/qpidd.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/qpid/cpp/src/qpidd.cpp b/qpid/cpp/src/qpidd.cpp
index 8e1b8c3d0a..64e64cab38 100644
--- a/qpid/cpp/src/qpidd.cpp
+++ b/qpid/cpp/src/qpidd.cpp
@@ -19,7 +19,6 @@
*
*/
#include "qpid/broker/Broker.h"
-#include "qpid/broker/SignalHandler.h"
#include "qpid/sys/posix/check.h"
#include "qpid/broker/Daemon.h"
#include "qpid/log/Statement.h"
@@ -132,6 +131,12 @@ struct BootstrapOptions : public qpid::Options {
shared_ptr<Broker> brokerPtr;
auto_ptr<QpiddOptions> options;
+void shutdownHandler(int /*signal*/){
+ // Note: do not call any async-signal unsafe functions here.
+ // Do any extra shutdown actions in main() after broker->run()
+ brokerPtr->shutdown();
+}
+
struct QpiddDaemon : public Daemon {
QpiddDaemon(std::string pidDir) : Daemon(pidDir) {}
@@ -148,6 +153,7 @@ struct QpiddDaemon : public Daemon {
uint16_t port=brokerPtr->getPort();
ready(port); // Notify parent.
brokerPtr->run();
+ brokerPtr.reset();
}
};
@@ -234,7 +240,17 @@ int main(int argc, char* argv[])
}
// Starting the broker.
- broker::SignalHandler::setBroker(brokerPtr); // Set up signal handling.
+
+ // Signal handling
+ signal(SIGINT,shutdownHandler);
+ signal(SIGTERM,shutdownHandler);
+ signal(SIGHUP,SIG_IGN); // TODO aconway 2007-07-18: reload config.
+
+ signal(SIGCHLD,SIG_IGN);
+ signal(SIGTSTP,SIG_IGN);
+ signal(SIGTTOU,SIG_IGN);
+ signal(SIGTTIN,SIG_IGN);
+
if (options->daemon.daemon) {
// For daemon mode replace default stderr with syslog.
if (options->log.outputs.size() == 1 && options->log.outputs[0] == "stderr") {