From a5b7064eee9951b9bcb9dfe50895a62772b7bacf Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 13 Oct 2009 19:53:43 +0000 Subject: Have qpidd -q wait till the qpidd process exits before returning. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@824894 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/posix/QpiddBroker.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/posix/QpiddBroker.cpp b/cpp/src/posix/QpiddBroker.cpp index aa934571be..3a20087062 100644 --- a/cpp/src/posix/QpiddBroker.cpp +++ b/cpp/src/posix/QpiddBroker.cpp @@ -144,8 +144,16 @@ int QpiddBroker::execute (QpiddOptions *options) { return 1; if (myOptions->daemon.check) cout << pid << endl; - if (myOptions->daemon.quit && kill(pid, SIGINT) < 0) - throw Exception("Failed to stop daemon: " + qpid::sys::strError(errno)); + if (myOptions->daemon.quit) { + if (kill(pid, SIGINT) < 0) + throw Exception("Failed to stop daemon: " + qpid::sys::strError(errno)); + // Wait for the process to die before returning + int retry=10000; // Try up to 10 seconds + while (kill(pid,0) == 0 && --retry) + sys::usleep(1000); + if (retry == 0) + throw Exception("Gave up waiting for daemon process to exit"); + } return 0; } -- cgit v1.2.1