diff options
author | Ted Ross <tross@apache.org> | 2008-11-06 18:29:31 +0000 |
---|---|---|
committer | Ted Ross <tross@apache.org> | 2008-11-06 18:29:31 +0000 |
commit | d1120dc4f0c20cd4ad0ee576e19f316fe19d3c71 (patch) | |
tree | f88afeef5a560861d0794e739b132851db51ef2e /cpp/examples/qmf-agent/example.cpp | |
parent | 54a9a26d27a59b2cc409bc7aee4c4cfcf2da8b00 (diff) | |
download | qpid-python-d1120dc4f0c20cd4ad0ee576e19f316fe19d3c71.tar.gz |
QPID-1437 - Made example better able to demonstrate proper shutdown by adding a signal handler
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@711933 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/examples/qmf-agent/example.cpp')
-rw-r--r-- | cpp/examples/qmf-agent/example.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/cpp/examples/qmf-agent/example.cpp b/cpp/examples/qmf-agent/example.cpp index e24e729e1d..8c47a0c366 100644 --- a/cpp/examples/qmf-agent/example.cpp +++ b/cpp/examples/qmf-agent/example.cpp @@ -29,6 +29,7 @@ #include "qmf/org/apache/qpid/agent/example/EventChildCreated.h" #include "qmf/org/apache/qpid/agent/example/Package.h" +#include <signal.h> #include <unistd.h> #include <cstdlib> #include <iostream> @@ -149,14 +150,25 @@ ChildClass::ChildClass(ManagementAgent* agent, CoreClass* parent, string name) //============================================================== // Main program //============================================================== + +ManagementAgent::Singleton* singleton; + +void shutdown(int) +{ + delete singleton; + exit(0); +} + int main_int(int argc, char** argv) { - ManagementAgent::Singleton singleton; + singleton = new ManagementAgent::Singleton(); const char* host = argc>1 ? argv[1] : "127.0.0.1"; int port = argc>2 ? atoi(argv[2]) : 5672; + signal(SIGINT, shutdown); + // Create the qmf management agent - ManagementAgent* agent = singleton.getInstance(); + ManagementAgent* agent = singleton->getInstance(); // Register the Qmf_example schema with the agent _qmf::Package packageInit(agent); |