diff options
author | Jan Holesovsky <kendy@collabora.com> | 2019-11-06 10:07:32 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2019-11-07 12:23:47 +0100 |
commit | 5b5e29b4303ffff0b8e2fc91bcccd772a42a78f7 (patch) | |
tree | 2b4f234aba5161cd5ac5e5e37336d49e864b765d | |
parent | 58b4734f9e18b652bfc0eee8e1fef476e5dd62d7 (diff) |
killpoco: Don't use POCO for app exit values.
Change-Id: I2948ac45a7b4243f7afde08d5245530fdbf9a070
Reviewed-on: https://gerrit.libreoffice.org/82125
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r-- | common/Unit.cpp | 7 | ||||
-rw-r--r-- | kit/ForKit.cpp | 19 | ||||
-rw-r--r-- | kit/Kit.cpp | 25 | ||||
-rw-r--r-- | test/UnitTimeout.cpp | 9 | ||||
-rw-r--r-- | tools/Config.cpp | 11 | ||||
-rw-r--r-- | tools/Connect.cpp | 7 | ||||
-rw-r--r-- | tools/KitClient.cpp | 9 | ||||
-rw-r--r-- | tools/Stress.cpp | 7 | ||||
-rw-r--r-- | tools/Tool.cpp | 7 | ||||
-rw-r--r-- | tools/map.cpp | 1 | ||||
-rw-r--r-- | wsd/LOOLWSD.cpp | 13 |
11 files changed, 58 insertions, 57 deletions
diff --git a/common/Unit.cpp b/common/Unit.cpp index 151a4505d..8682aa45d 100644 --- a/common/Unit.cpp +++ b/common/Unit.cpp @@ -15,9 +15,10 @@ #include <cassert> #include <dlfcn.h> #include <fstream> +#include <sysexits.h> #include <Poco/Thread.h> -#include <Poco/Util/Application.h> +#include <Poco/Util/LayeredConfiguration.h> #include "Log.hpp" #include "Util.hpp" @@ -186,9 +187,7 @@ void UnitBase::exitTest(TestResult result) { LOG_INF("exitTest: " << (int)result << ". Flagging for termination."); _setRetValue = true; - _retValue = result == TestResult::Ok ? - Poco::Util::Application::EXIT_OK : - Poco::Util::Application::EXIT_SOFTWARE; + _retValue = result == TestResult::Ok ? EX_OK : EX_SOFTWARE; SigUtil::setTerminationFlag(); SocketPoll::wakeupWorld(); } diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index c6e2ebd4a..7150ee6ab 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -17,6 +17,7 @@ #include <sys/stat.h> #include <sys/types.h> #include <sys/wait.h> +#include <sysexits.h> #include <atomic> #include <cstdlib> @@ -27,7 +28,6 @@ #include <Poco/Path.h> #include <Poco/Process.h> #include <Poco/Thread.h> -#include <Poco/Util/Application.h> #include <Common.hpp> #include <IoUtil.hpp> @@ -43,9 +43,6 @@ using Poco::Process; using Poco::Thread; -#ifndef KIT_IN_PROCESS -using Poco::Util::Application; -#endif #ifndef KIT_IN_PROCESS static bool NoCapsForKit = false; @@ -353,7 +350,7 @@ int main(int argc, char** argv) { if (!hasCorrectUID("loolforkit")) { - return Application::EXIT_SOFTWARE; + return EX_SOFTWARE; } if (std::getenv("SLEEPFORDEBUGGER")) @@ -490,14 +487,14 @@ int main(int argc, char** argv) loTemplate.empty() || childRoot.empty()) { printArgumentHelp(); - return Application::EXIT_USAGE; + return EX_USAGE; } if (!UnitBase::init(UnitBase::UnitType::Kit, UnitTestLibrary)) { LOG_ERR("Failed to load kit unit test library"); - return Application::EXIT_USAGE; + return EX_USAGE; } // Setup & check environment @@ -528,7 +525,7 @@ int main(int argc, char** argv) std::cerr << "FATAL: Capabilities are not set for the loolforkit program." << std::endl; std::cerr << "Please make sure that the current partition was *not* mounted with the 'nosuid' option." << std::endl; std::cerr << "If you are on SLES11, please set 'file_caps=1' as kernel boot option." << std::endl << std::endl; - return Application::EXIT_SOFTWARE; + return EX_SOFTWARE; } // Set various options we need. @@ -542,7 +539,7 @@ int main(int argc, char** argv) { LOG_FTL("Failed to preinit lokit."); Log::shutdown(); - std::_Exit(Application::EXIT_SOFTWARE); + std::_Exit(EX_SOFTWARE); } if (Util::getProcessThreadCount() != 1) @@ -558,7 +555,7 @@ int main(int argc, char** argv) { LOG_FTL("Failed to create a kit process."); Log::shutdown(); - std::_Exit(Application::EXIT_SOFTWARE); + std::_Exit(EX_SOFTWARE); } // No need to trace subsequent children. @@ -585,7 +582,7 @@ int main(int argc, char** argv) forkLibreOfficeKit(childRoot, sysTemplate, loTemplate, loSubPath); } - int returnValue = Application::EXIT_OK; + int returnValue = EX_OK; UnitKit::get().returnValue(returnValue); #if 0 diff --git a/kit/Kit.cpp b/kit/Kit.cpp index 6ae7e0eec..cd397d397 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -23,6 +23,7 @@ #include <utime.h> #include <sys/time.h> #include <sys/resource.h> +#include <sysexits.h> #include <atomic> #include <cassert> @@ -52,7 +53,6 @@ #include <Poco/StringTokenizer.h> #include <Poco/Thread.h> #include <Poco/URI.h> -#include <Poco/Util/Application.h> #include "ChildSession.hpp" #include <Common.hpp> @@ -99,7 +99,6 @@ using Poco::JSON::Parser; using Poco::StringTokenizer; using Poco::Thread; using Poco::URI; -using Poco::Util::Application; #ifndef BUILDING_TESTS using Poco::Path; @@ -224,7 +223,7 @@ namespace LOG_FTL("Copying of '" << fpath << "' to " << newPath.toString() << " failed: " << exc.what() << ". Exiting."); Log::shutdown(); - std::_Exit(Application::EXIT_SOFTWARE); + std::_Exit(EX_SOFTWARE); } } } @@ -841,7 +840,7 @@ public: { LOG_FTL("Document [" << anonymizeUrl(_url) << "] has no more views, exiting bluntly."); Log::shutdown(); - std::_Exit(Application::EXIT_OK); + std::_Exit(EX_OK); } #endif } @@ -1386,7 +1385,7 @@ private: { LOG_INF("Document [" << anonymizeUrl(_url) << "] has no more views, exiting bluntly."); Log::shutdown(); - std::_Exit(Application::EXIT_OK); + std::_Exit(EX_OK); } #endif LOG_INF("Document [" << anonymizeUrl(_url) << "] has no more views, but has " << @@ -1976,7 +1975,7 @@ public: LOG_FTL("QueueHandler::run: Exception: " << exc.what()); #if !MOBILEAPP Log::shutdown(); - std::_Exit(Application::EXIT_SOFTWARE); + std::_Exit(EX_SOFTWARE); #endif } catch (...) @@ -1984,7 +1983,7 @@ public: LOG_FTL("QueueHandler::run: Unknown exception"); #if !MOBILEAPP Log::shutdown(); - std::_Exit(Application::EXIT_SOFTWARE); + std::_Exit(EX_SOFTWARE); #endif } } @@ -2456,14 +2455,14 @@ void lokit_main( { LOG_SFL("chroot(\"" << jailPath.toString() << "\") failed."); Log::shutdown(); - std::_Exit(Application::EXIT_SOFTWARE); + std::_Exit(EX_SOFTWARE); } if (chdir("/") == -1) { LOG_SFL("chdir(\"/\") in jail failed."); Log::shutdown(); - std::_Exit(Application::EXIT_SOFTWARE); + std::_Exit(EX_SOFTWARE); } dropCapability(CAP_SYS_CHROOT); @@ -2506,7 +2505,7 @@ void lokit_main( { LOG_FTL("LibreOfficeKit initialization failed. Exiting."); Log::shutdown(); - std::_Exit(Application::EXIT_SOFTWARE); + std::_Exit(EX_SOFTWARE); } } @@ -2517,7 +2516,7 @@ void lokit_main( { LOG_FTL("LibreOfficeKit seccomp security lockdown failed. Exiting."); Log::shutdown(); - std::_Exit(Application::EXIT_SOFTWARE); + std::_Exit(EX_SOFTWARE); } LOG_ERR("LibreOfficeKit seccomp security lockdown failed, but configured to continue. " @@ -2615,7 +2614,7 @@ void lokit_main( { LOG_ERR("Kit is missing Unipoll API"); std::cout << "Fatal: out of date LibreOfficeKit - no Unipoll API\n"; - std::_Exit(Application::EXIT_SOFTWARE); + std::_Exit(EX_SOFTWARE); } LOG_INF("Kit unipoll loop run"); @@ -2652,7 +2651,7 @@ void lokit_main( LOG_INF("Process finished."); Log::shutdown(); std::unique_lock<std::mutex> lock(SigUtil::getSigHandlerTrap()); - std::_Exit(Application::EXIT_OK); + std::_Exit(EX_OK); #endif } diff --git a/test/UnitTimeout.cpp b/test/UnitTimeout.cpp index fc9881285..d0b2de79c 100644 --- a/test/UnitTimeout.cpp +++ b/test/UnitTimeout.cpp @@ -10,8 +10,7 @@ #include <config.h> #include <cassert> - -#include <Poco/Util/Application.h> +#include <sysexits.h> #include <Log.hpp> #include <Util.hpp> @@ -36,14 +35,14 @@ public: if (!_timedOut) { LOG_INF("Failed to timeout"); - retValue = Poco::Util::Application::EXIT_SOFTWARE; + retValue = EX_SOFTWARE; } else { assert(_setRetValue); - assert(_retValue == Poco::Util::Application::EXIT_SOFTWARE); + assert(_retValue == EX_SOFTWARE); // we wanted a timeout. - retValue = Poco::Util::Application::EXIT_OK; + retValue = EX_OK; } } diff --git a/tools/Config.cpp b/tools/Config.cpp index 2cf45ac3f..754062a4e 100644 --- a/tools/Config.cpp +++ b/tools/Config.cpp @@ -12,6 +12,7 @@ #include <iostream> #include <iomanip> #include <sstream> +#include <sysexits.h> #include <termios.h> #include <openssl/rand.h> @@ -164,7 +165,7 @@ void Config::handleOption(const std::string& optionName, const std::string& opti if (optionName == "help") { displayHelp(); - std::exit(Application::EXIT_OK); + std::exit(EX_OK); } else if (optionName == "config-file") { @@ -219,10 +220,10 @@ int Config::main(const std::vector<std::string>& args) { std::cerr << "Nothing to do." << std::endl; displayHelp(); - return Application::EXIT_NOINPUT; + return EX_NOINPUT; } - int retval = Application::EXIT_OK; + int retval = EX_OK; bool changed = false; _loolConfig.load(ConfigFile); @@ -262,7 +263,7 @@ int Config::main(const std::vector<std::string>& args) if (adminPwd != reAdminPwd) { std::cout << "Password mismatch." << std::endl; - return Application::EXIT_DATAERR; + return EX_DATAERR; } // Do the magic ! @@ -297,7 +298,7 @@ int Config::main(const std::vector<std::string>& args) changed = true; #else std::cerr << "This application was compiled with old OpenSSL. Operation not supported. You can use plain text password in /etc/loolwsd/loolwsd.xml." << std::endl; - return Application::EXIT_UNAVAILABLE; + return EX_UNAVAILABLE; #endif } #if ENABLE_SUPPORT_KEY diff --git a/tools/Connect.cpp b/tools/Connect.cpp index 985ce681b..146d98294 100644 --- a/tools/Connect.cpp +++ b/tools/Connect.cpp @@ -14,6 +14,7 @@ #include <fstream> #include <iostream> #include <mutex> +#include <sysexits.h> #include <thread> #include <Poco/Net/AcceptCertificateHandler.h> @@ -114,7 +115,7 @@ public: std::cout << "CLOSE frame received" << std::endl; } if (!closeExpected) - std::_Exit(Application::EXIT_SOFTWARE); + std::_Exit(EX_SOFTWARE); } catch (WebSocketException& exc) { @@ -146,7 +147,7 @@ protected: if (args.size() < 1) { LOG_ERR("Usage: connect documentURI [serverURI]"); - return Application::EXIT_USAGE; + return EX_USAGE; } if (args.size() > 1) @@ -228,7 +229,7 @@ protected: ws.shutdown(); thread.join(); - return Application::EXIT_OK; + return EX_OK; } private: diff --git a/tools/KitClient.cpp b/tools/KitClient.cpp index fdb4ffa84..a869a86f0 100644 --- a/tools/KitClient.cpp +++ b/tools/KitClient.cpp @@ -15,6 +15,7 @@ #include <fstream> #include <iostream> #include <memory> +#include <sysexits.h> #define LOK_USE_UNSTABLE_API #include <LibreOfficeKit/LibreOfficeKitInit.h> @@ -54,7 +55,7 @@ protected: if (args.size() != 2) { logger().fatal("Usage: lokitclient /path/to/lo/installation/program /path/to/document"); - return Application::EXIT_USAGE; + return EX_USAGE; } LibreOfficeKit *loKit; @@ -64,7 +65,7 @@ protected: if (!loKit) { logger().fatal("LibreOfficeKit initialisation failed"); - return Application::EXIT_UNAVAILABLE; + return EX_UNAVAILABLE; } @@ -72,7 +73,7 @@ protected: if (!loKitDocument) { logger().fatal("Document loading failed: " + std::string(loKit->pClass->getError(loKit))); - return Application::EXIT_UNAVAILABLE; + return EX_UNAVAILABLE; } loKitDocument->pClass->registerCallback(loKitDocument, myCallback, nullptr); @@ -162,7 +163,7 @@ protected: } // Safest to just bluntly exit - std::_Exit(Application::EXIT_OK); + std::_Exit(EX_OK); } }; diff --git a/tools/Stress.cpp b/tools/Stress.cpp index 76e887602..1a4d17124 100644 --- a/tools/Stress.cpp +++ b/tools/Stress.cpp @@ -18,6 +18,7 @@ #include <fstream> #include <iostream> #include <numeric> +#include <sysexits.h> #include <thread> #include <Poco/Net/HTTPRequest.h> @@ -258,7 +259,7 @@ void Stress::handleOption(const std::string& optionName, helpFormatter.setUsage("OPTIONS"); helpFormatter.setHeader("LibreOffice Online tool."); helpFormatter.format(std::cerr); - std::exit(Application::EXIT_OK); + std::exit(EX_OK); } else if (optionName == "bench") Stress::Benchmark = true; @@ -286,7 +287,7 @@ int Stress::main(const std::vector<std::string>& args) std::cerr << "Usage: loolstress [--bench] <tracefile | url> " << std::endl; std::cerr << " Trace files may be plain text or gzipped (with .gz extension)." << std::endl; std::cerr << " --help for full arguments list." << std::endl; - return Application::EXIT_NOINPUT; + return EX_NOINPUT; } std::vector<std::shared_ptr<Worker>> workers; @@ -347,7 +348,7 @@ int Stress::main(const std::vector<std::string>& args) } } - return Application::EXIT_OK; + return EX_OK; } POCO_APP_MAIN(Stress) diff --git a/tools/Tool.cpp b/tools/Tool.cpp index 8957f6acc..91fe4600a 100644 --- a/tools/Tool.cpp +++ b/tools/Tool.cpp @@ -16,6 +16,7 @@ #include <cstring> #include <fstream> #include <iostream> +#include <sysexits.h> #include <Poco/Net/HTMLForm.h> #include <Poco/Net/HTTPClientSession.h> @@ -179,7 +180,7 @@ void Tool::handleOption(const std::string& optionName, if (optionName == "help") { displayHelp(); - std::exit(Application::EXIT_OK); + std::exit(EX_OK); } else if (optionName == "extension" || optionName == "convert-to") @@ -246,7 +247,7 @@ int Tool::main(const std::vector<std::string>& origArgs) { std::cerr << "Nothing to do." << std::endl; displayHelp(); - return Application::EXIT_NOINPUT; + return EX_NOINPUT; } std::vector<std::unique_ptr<Thread>> clients(_numWorkers); @@ -271,7 +272,7 @@ int Tool::main(const std::vector<std::string>& origArgs) clients[i]->join(); } - return Application::EXIT_OK; + return EX_OK; } POCO_APP_MAIN(Tool) diff --git a/tools/map.cpp b/tools/map.cpp index 845adfa07..d2ebb5d6e 100644 --- a/tools/map.cpp +++ b/tools/map.cpp @@ -12,6 +12,7 @@ #include <vector> #include <iostream> #include <sstream> +#include <sysexits.h> #include <unordered_map> #include <unordered_set> diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index b8b826568..ac42e490a 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -33,6 +33,7 @@ // number of child processes, each which handles a viewing (editing) session for one document. #include <unistd.h> +#include <sysexits.h> #include <sys/stat.h> #include <sys/types.h> @@ -999,7 +1000,7 @@ void LOOLWSD::initialize(Application& self) "'--o:logging.level=trace' from the command line in Makefile.am.\n" << std::endl; #endif Log::shutdown(); - _exit(Application::EXIT_SOFTWARE); + _exit(EX_SOFTWARE); } } @@ -1373,7 +1374,7 @@ void LOOLWSD::handleOption(const std::string& optionName, if (optionName == "help") { displayHelp(); - std::exit(Application::EXIT_OK); + std::exit(EX_OK); } else if (optionName == "version") DisplayVersion = true; @@ -3246,7 +3247,7 @@ private: { LOG_FTL("Failed to create local unix domain socket. Exiting."); Log::shutdown(); - _exit(Application::EXIT_SOFTWARE); + _exit(EX_SOFTWARE); return nullptr; } @@ -3254,7 +3255,7 @@ private: { LOG_FTL("Failed to listen on local unix domain socket at " << location << ". Exiting."); Log::shutdown(); - _exit(Application::EXIT_SOFTWARE); + _exit(EX_SOFTWARE); } LOG_INF("Listening to prisoner connections on " << location); @@ -3298,7 +3299,7 @@ private: { LOG_FTL("Failed to listen on Server port(s) (" << ClientPortNumber << '-' << port << "). Exiting."); - _exit(Application::EXIT_SOFTWARE); + _exit(EX_SOFTWARE); } ClientPortNumber = port; @@ -3592,7 +3593,7 @@ int LOOLWSD::innerMain() } #endif // !MOBILEAPP - return Application::EXIT_OK; + return EX_OK; } void LOOLWSD::cleanup() |