diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2015-02-20 13:07:50 -0800 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2015-02-20 13:07:50 -0800 |
commit | 2f3e2ec86562e9894eda5f4422254713defa9367 (patch) | |
tree | 8de11550cff3e5a157b66e183e7bbf09f66ce1e3 | |
parent | 108f43b59b9319bd6cf838383a722d7a30d675c2 (diff) |
Make interop server respond to sigint
This will allow the test to shut down cleanly, and avoid failing.
-rw-r--r-- | test/cpp/interop/server.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/test/cpp/interop/server.cc b/test/cpp/interop/server.cc index 4869d4df52..263bd8e304 100644 --- a/test/cpp/interop/server.cc +++ b/test/cpp/interop/server.cc @@ -35,6 +35,8 @@ #include <sstream> #include <thread> +#include <signal.h> + #include <gflags/gflags.h> #include <grpc/grpc.h> #include <grpc/support/log.h> @@ -80,6 +82,8 @@ namespace gflags { } using namespace google; using namespace gflags; +static bool got_sigint = false; + bool SetPayload(PayloadType type, int size, Payload* payload) { PayloadType response_type = type; // TODO(yangg): Support UNCOMPRESSABLE payload. @@ -217,14 +221,17 @@ void RunServer() { } std::unique_ptr<Server> server(builder.BuildAndStart()); gpr_log(GPR_INFO, "Server listening on %s", server_address.str().c_str()); - while (true) { + while (!got_sigint) { std::this_thread::sleep_for(std::chrono::seconds(5)); } } +static void sigint_handler(int x) { got_sigint = true; } + int main(int argc, char** argv) { grpc_init(); ParseCommandLineFlags(&argc, &argv, true); + signal(SIGINT, sigint_handler); GPR_ASSERT(FLAGS_port != 0); RunServer(); |