From 0d8165fd16cb4b2596834772e93081947bea0e0d Mon Sep 17 00:00:00 2001 From: BenDroid Date: Fri, 30 Mar 2018 20:43:46 +0200 Subject: [PATCH] XMRigd now restarts miner in a case of segfault --- src/cc/XMRigd.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/cc/XMRigd.cpp b/src/cc/XMRigd.cpp index 2f08e612..bc4092df 100644 --- a/src/cc/XMRigd.cpp +++ b/src/cc/XMRigd.cpp @@ -24,13 +24,13 @@ #include #include +#include +#include #ifdef WIN32 #define WIN32_LEAN_AND_MEAN /* avoid including junk */ #include #include - #include - #include #else #include #include @@ -71,14 +71,24 @@ int main(int argc, char **argv) { do { status = system(xmrigMinerPath.c_str()); + + if (WEXITSTATUS(status) == 139) { + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + printf("Restarting."); + } #if defined(_WIN32) || defined(WIN32) - } while (status == EINTR); + } while (status == EINTR || status == 139); + + if (WEXITSTATUS(status) == 139) { + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + printf("Restarting."); + } if (status == EINVAL) { std::this_thread::sleep_for(std::chrono::milliseconds(5000)); } #else - } while (WEXITSTATUS(status) == EINTR); + } while (WEXITSTATUS(status) == EINTR || WEXITSTATUS(status) == 139); // segfault #endif }