diff options
Diffstat (limited to 'cpp/test/IceUtil/ctrlCHandler/Client.cpp')
-rw-r--r-- | cpp/test/IceUtil/ctrlCHandler/Client.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/cpp/test/IceUtil/ctrlCHandler/Client.cpp b/cpp/test/IceUtil/ctrlCHandler/Client.cpp new file mode 100644 index 00000000000..64407185a29 --- /dev/null +++ b/cpp/test/IceUtil/ctrlCHandler/Client.cpp @@ -0,0 +1,39 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <TestCommon.h> +#include <IceUtil/CtrlCHandler.h> +#include <IceUtil/Thread.h> +#include <IceUtil/Time.h> + +using namespace IceUtil; +using namespace std; + +void callback(int signal) +{ + cout << "Handling signal " << signal << endl; +} + +int main() +{ + { + cout << "First ignore CTRL+C and the like for 10 seconds (try it!)" << endl; + CtrlCHandler handler; + ThreadControl::sleep(Time::seconds(10)); + + cout << "Then handling them for another 30 seconds (try it)" << endl; + handler.setCallback(callback); + ThreadControl::sleep(Time::seconds(10)); + } + cout << "And another 10 seconds after ~CtrlCHandler" << endl; + ThreadControl::sleep(Time::seconds(10)); + + cout << "ok" << endl; + return EXIT_SUCCESS; +} |