summaryrefslogtreecommitdiff
path: root/cpp/src/posix
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/posix')
-rw-r--r--cpp/src/posix/QpiddBroker.cpp12
1 files changed, 10 insertions, 2 deletions
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;
}