diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bcf5996..4dfc18bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# v2.2.1 +- Fixed [terminal issues](https://github.com/xmrig/xmrig-proxy/issues/2#issuecomment-319914085) after exit on Linux and OS X. + # v2.2.0 - [#46](https://github.com/xmrig/xmrig/issues/46) Restored config file support. Now possible use multiple config files and combine with command line options also added support for default config. - Improved colors support on Windows, now used uv_tty, legacy code removed. diff --git a/src/App.cpp b/src/App.cpp index 4ef8a1a6..de6f2785 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -59,6 +59,9 @@ App::App(int argc, char **argv) : Cpu::init(); m_options = Options::parse(argc, argv); + if (!m_options) { + return; + } Log::init(); @@ -91,7 +94,7 @@ App::~App() int App::exec() { - if (!m_options->isReady()) { + if (!m_options) { return 0; } @@ -115,6 +118,7 @@ int App::exec() const int r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); uv_loop_close(uv_default_loop()); + uv_tty_reset_mode(); free(m_network); free(m_options); diff --git a/src/Console.cpp b/src/Console.cpp index 15c99001..3d95ada4 100644 --- a/src/Console.cpp +++ b/src/Console.cpp @@ -31,8 +31,12 @@ Console::Console(IConsoleListener *listener) { m_tty.data = this; uv_tty_init(uv_default_loop(), &m_tty, 0, 1); - uv_tty_set_mode(&m_tty, UV_TTY_MODE_RAW); + if (!uv_is_readable(reinterpret_cast(&m_tty))) { + return; + } + + uv_tty_set_mode(&m_tty, UV_TTY_MODE_RAW); uv_read_start(reinterpret_cast(&m_tty), Console::onAllocBuffer, Console::onRead); } diff --git a/src/Options.cpp b/src/Options.cpp index a94af60d..1a1e1c69 100644 --- a/src/Options.cpp +++ b/src/Options.cpp @@ -181,11 +181,14 @@ static char *defaultConfigName() Options *Options::parse(int argc, char **argv) { - if (!m_self) { - m_self = new Options(argc, argv); + Options *options = new Options(argc, argv); + if (options->isReady()) { + m_self = options; + return m_self; } - return m_self; + delete options; + return nullptr; } diff --git a/src/Options.h b/src/Options.h index 0b41f5c4..7a6a7339 100644 --- a/src/Options.h +++ b/src/Options.h @@ -57,7 +57,6 @@ public: inline bool background() const { return m_background; } inline bool colors() const { return m_colors; } inline bool doubleHash() const { return m_doubleHash; } - inline bool isReady() const { return m_ready; } inline bool syslog() const { return m_syslog; } inline const char *logFile() const { return m_logFile; } inline const std::vector &pools() const { return m_pools; } @@ -76,6 +75,8 @@ private: Options(int argc, char **argv); ~Options(); + inline bool isReady() const { return m_ready; } + static Options *m_self; bool parseArg(int key, const char *arg); diff --git a/src/version.h b/src/version.h index 08bd362b..3d197ee3 100644 --- a/src/version.h +++ b/src/version.h @@ -27,14 +27,14 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "Monero (XMR) CPU miner" -#define APP_VERSION "2.2.0-dev" +#define APP_VERSION "2.2.1" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2017 xmrig.com" #define APP_VER_MAJOR 2 #define APP_VER_MINOR 2 -#define APP_VER_BUILD 0 +#define APP_VER_BUILD 1 #define APP_VER_REV 0 #ifdef _MSC_VER