From bec1e69755d1708834a5944e0b36cd874c1983b5 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 19 Nov 2017 13:54:30 +0000 Subject: [PATCH] Add windows exit --- xmrstak/cli/cli-miner.cpp | 11 ++++++----- xmrstak/misc/console.cpp | 9 +++++---- xmrstak/misc/console.hpp | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/xmrstak/cli/cli-miner.cpp b/xmrstak/cli/cli-miner.cpp index 90da8348c..e152a026f 100644 --- a/xmrstak/cli/cli-miner.cpp +++ b/xmrstak/cli/cli-miner.cpp @@ -302,18 +302,19 @@ int main(int argc, char *argv[]) if(opName.compare("-h") == 0 || opName.compare("--help") == 0) { help(); - // \todo give return code to win_exit to allow passing CI - //win_exit(); + win_exit(0); return 0; } if(opName.compare("-v") == 0 || opName.compare("--version") == 0) { std::cout<< "Version: " << get_version_str_short() << std::endl; + win_exit(); return 0; } else if(opName.compare("-V") == 0 || opName.compare("--version-long") == 0) { std::cout<< "Version: " << get_version_str() << std::endl; + win_exit(); return 0; } else if(opName.compare("--noCPU") == 0) @@ -432,13 +433,13 @@ int main(int argc, char *argv[]) if(!jconf::inst()->parse_config(params::inst().configFile.c_str())) { win_exit(); - return 0; + return 1; } if (!BackendConnector::self_test()) { win_exit(); - return 0; + return 1; } #ifndef CONF_NO_HTTPD @@ -447,7 +448,7 @@ int main(int argc, char *argv[]) if (!httpd::inst()->start_daemon()) { win_exit(); - return 0; + return 1; } } #endif diff --git a/xmrstak/misc/console.cpp b/xmrstak/misc/console.cpp index ce63bcb52..8de5948bc 100644 --- a/xmrstak/misc/console.cpp +++ b/xmrstak/misc/console.cpp @@ -220,15 +220,16 @@ void printer::print_str(const char* str) //Do a press any key for the windows folk. *insert any key joke here* #ifdef _WIN32 -void win_exit() +void win_exit(size_t code) { printer::inst()->print_str("Press any key to exit."); get_key(); - std::exit(1); + std::exit(code); } #else -void win_exit() { - std::exit(1); +void win_exit(size_t code) +{ + std::exit(code); } #endif // _WIN32 diff --git a/xmrstak/misc/console.hpp b/xmrstak/misc/console.hpp index 97e86bd74..cfbeddd01 100644 --- a/xmrstak/misc/console.hpp +++ b/xmrstak/misc/console.hpp @@ -49,4 +49,4 @@ class printer FILE* logfile; }; -void win_exit(); +void win_exit(size_t code = 1);