Revert "Handle crash exceptions by trying to restart cgminer unless the --no-restart option is used." This reverts commit 68c881fde72f7aa92224cf4e4ba67a5af868dafc. Does not reliably restart on crashes often enough and makes debugging more difficult.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
diff --git a/README b/README
index 316d695..9ac417d 100644
--- a/README
+++ b/README
@@ -154,7 +154,6 @@ Options for both config file and command line:
--monitor|-m <arg> Use custom pipe cmd for output messages
--net-delay Impose small delays in networking to not overload slow routers
--no-pool-disable Do not automatically disable pools that continually reject shares
---no-restart Do not attempt to restart GPUs that hang or cgminer if it crashes
--no-submit-stale Don't submit shares if they are detected as stale
--pass|-p <arg> Password for bitcoin JSON-RPC server
--per-device-stats Force verbose mode and output per-device statistics
@@ -205,6 +204,7 @@ GPU only options:
--intensity|-I <arg> Intensity of GPU scanning (d or -10 -> 10, default: d to maintain desktop interactivity)
--kernel|-k <arg> Override kernel to use (diablo, poclbm, phatk or diakgcn) - one value or comma separated
--ndevs|-n Enumerate number of detected GPUs and exit
+--no-restart Do not attempt to restart GPUs that hang
--temp-hysteresis <arg> Set how much the temperature can fluctuate outside limits when automanaging speeds (default: 3)
--temp-overheat <arg> Overheat temperature when automatically managing fan and GPU speeds (default: 85)
--temp-target <arg> Target temperature when automatically managing fan and GPU speeds (default: 75)
diff --git a/cgminer.c b/cgminer.c
index 21b44dd..cd2c12a 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -264,7 +264,7 @@ static int include_count;
bool ping = true;
-struct sigaction termhandler, inthandler, segvhandler, bushandler, illhandler;
+struct sigaction termhandler, inthandler;
struct thread_q *getq;
@@ -987,7 +987,7 @@ static struct opt_table opt_config_table[] = {
OPT_WITHOUT_ARG("--no-restart",
opt_set_invbool, &opt_restart,
#ifdef HAVE_OPENCL
- "Do not attempt to restart GPUs that hang or cgminer if it crashes"
+ "Do not attempt to restart GPUs that hang"
#else
opt_hidden
#endif
@@ -2768,8 +2768,13 @@ char **initial_args;
static void clean_up(void);
-static inline void __app_restart(void)
+void app_restart(void)
{
+ applog(LOG_WARNING, "Attempting to restart %s", packagename);
+
+ __kill_work();
+ clean_up();
+
#if defined(unix)
if (forkpid > 0) {
kill(forkpid, SIGTERM);
@@ -2778,55 +2783,17 @@ static inline void __app_restart(void)
#endif
execv(initial_args[0], initial_args);
-}
-
-void app_restart(void)
-{
- applog(LOG_WARNING, "Attempting to restart %s", packagename);
-
- __kill_work();
- clean_up();
-
- __app_restart();
-
- /* We shouldn't reach here */
applog(LOG_WARNING, "Failed to restart application");
}
-/* Returns all signal handlers to their defaults */
-static inline void __sighandler(void)
+static void sighandler(int __maybe_unused sig)
{
/* Restore signal handlers so we can still quit if kill_work fails */
sigaction(SIGTERM, &termhandler, NULL);
sigaction(SIGINT, &inthandler, NULL);
- if (opt_restart) {
- sigaction(SIGSEGV, &segvhandler, NULL);
- sigaction(SIGILL, &illhandler, NULL);
-#ifndef WIN32
- sigaction(SIGBUS, &bushandler, NULL);
-#endif
- }
-}
-
-static void sighandler(int __maybe_unused sig)
-{
- __sighandler();
kill_work();
}
-/* Handles segfaults and other crashes by attempting to restart cgminer. Try to
- * do as little as possible since we are probably corrupted. */
-static void seghandler(int sig)
-{
- __sighandler();
- fprintf(stderr, "\nCrashed with signal %d! Will attempt to restart\n", sig);
- __app_restart();
- /* We shouldn't reach here */
- fprintf(stderr, "Failed to restart, exiting now\n");
-
- exit(1);
-}
-
/* Called with pool_lock held. Recruit an extra curl if none are available for
* this pool. */
static void recruit_curl(struct pool *pool)
@@ -6699,18 +6666,6 @@ int main(int argc, char *argv[])
if (!config_loaded)
load_default_config();
- if (opt_restart) {
- struct sigaction shandler;
-
- shandler.sa_handler = &seghandler;
- shandler.sa_flags = 0;
- sigemptyset(&shandler.sa_mask);
- sigaction(SIGSEGV, &shandler, &segvhandler);
- sigaction(SIGILL, &shandler, &illhandler);
-#ifndef WIN32
- sigaction(SIGBUS, &shandler, &bushandler);
-#endif
- }
if (opt_benchmark) {
struct pool *pool;