summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/qpidd.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2006-12-23 17:20:37 +0000
committerAlan Conway <aconway@apache.org>2006-12-23 17:20:37 +0000
commit1a5f3f72cc85d88e23d47d4b7ccb52c281205942 (patch)
tree6956f3a3136b4676b45358706823ad3fe64ed060 /qpid/cpp/src/qpidd.cpp
parent42e76f82d4a28a521433a2542dae32436b98aef7 (diff)
downloadqpid-python-1a5f3f72cc85d88e23d47d4b7ccb52c281205942.tar.gz
- rpm: make rpm now builds RPMs under rpm/ directory.
- src/qpidd.cpp: added --daemon option to run as daemon. - etc/qpidd: fixed bugs in init.rc script. - qpidc.spec: fixed rpmlint warnings, added apache URL git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@489905 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/qpidd.cpp')
-rw-r--r--qpid/cpp/src/qpidd.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/qpid/cpp/src/qpidd.cpp b/qpid/cpp/src/qpidd.cpp
index 8285f1aefb..9f658ebf74 100644
--- a/qpid/cpp/src/qpidd.cpp
+++ b/qpid/cpp/src/qpidd.cpp
@@ -23,7 +23,9 @@
#include <signal.h>
#include <iostream>
#include <memory>
+#include <cerrno>
#include <config.h>
+#include <unistd.h>
static char const* programName = "qpidd";
@@ -42,6 +44,7 @@ int main(int argc, char** argv)
Configuration config;
try {
config.parse(programName, argc, argv);
+
if(config.isHelp()){
config.usage();
}else if(config.isVersion()){
@@ -50,9 +53,26 @@ int main(int argc, char** argv)
}else{
broker = Broker::create(config);
signal(SIGINT, handle_signal);
+ if (config.isDaemon()) {
+ // Detach & run as daemon.
+ int chdirRoot = 0; // 0 means chdir to root.
+ int closeStd = 0; // 0 means close stdin/out/err
+ if (daemon(chdirRoot, closeStd) < 0) {
+ char buf[512];
+
+ std::cerr << "Failed to detach as daemon: "
+ << strerror_r(errno, buf, sizeof(buf))
+ << std::endl;;
+ return 1;
+ }
+ }
broker->run();
}
return 0;
+ }
+ catch (const Configuration::BadOptionException& e) {
+ std::cerr << e.what() << std::endl << std::endl;
+ config.usage();
} catch(const std::exception& e) {
std::cerr << e.what() << std::endl;
}