diff options
author | Stephen D. Huston <shuston@apache.org> | 2009-09-17 19:37:35 +0000 |
---|---|---|
committer | Stephen D. Huston <shuston@apache.org> | 2009-09-17 19:37:35 +0000 |
commit | 3d2cccc5412522bbf2e1fb280ad0f4f74d7695b4 (patch) | |
tree | 1f4f6a5f23504b4237cec19f757153edbfb53e56 /cpp | |
parent | b792f14784600e7a85b41b5dba12bad8560a9077 (diff) | |
download | qpid-python-3d2cccc5412522bbf2e1fb280ad0f4f74d7695b4.tar.gz |
Add console control handler to properly shut down broker on ^C et al; fixes QPID-2109
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@816348 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/windows/QpiddBroker.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/cpp/src/windows/QpiddBroker.cpp b/cpp/src/windows/QpiddBroker.cpp index 5c6eef48f8..5bf9477e6a 100644 --- a/cpp/src/windows/QpiddBroker.cpp +++ b/cpp/src/windows/QpiddBroker.cpp @@ -133,6 +133,14 @@ void ShutdownHandler::run() { } } +// Console control handler to properly handle ctl-c. +BOOL CtrlHandler(DWORD ctl) +{ + ShutdownEvent shutter; // no pid specified == shut me down + shutter.signal(); + return ((ctl == CTRL_C_EVENT || ctl == CTRL_CLOSE_EVENT) ? TRUE : FALSE); +} + } struct ProcessControlOptions : public qpid::Options { @@ -245,6 +253,7 @@ int QpiddBroker::execute (QpiddOptions *options) { ShutdownHandler waitShut(brokerPtr); qpid::sys::Thread waitThr(waitShut); // Wait for shutdown event + SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE); brokerPtr->run(); waitShut.signal(); // In case we shut down some other way waitThr.join(); |