| 72 | } |
| 73 | |
| 74 | static void setup(double timeout_seconds = 20.0) FL_NOEXCEPT { |
| 75 | const char* disable_env = getenv("FASTLED_DISABLE_TIMEOUT_WATCHDOG"); |
| 76 | if (disable_env && (strcmp(disable_env, "1") == 0 || strcmp(disable_env, "true") == 0)) { |
| 77 | return; |
| 78 | } |
| 79 | |
| 80 | const char* timeout_env = getenv("FASTLED_TEST_TIMEOUT"); |
| 81 | if (timeout_env) { |
| 82 | double parsed = atof(timeout_env); |
| 83 | if (parsed > 0.0) { |
| 84 | timeout_seconds = parsed; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | g_timeout_seconds = timeout_seconds; |
| 89 | g_active = true; |
| 90 | |
| 91 | struct sigaction sa; |
| 92 | memset(&sa, 0, sizeof(sa)); |
| 93 | sa.sa_handler = alarm_handler; |
| 94 | sigemptyset(&sa.sa_mask); |
| 95 | sa.sa_flags = 0; |
| 96 | |
| 97 | if (sigaction(SIGALRM, &sa, nullptr) == 0) { |
| 98 | alarm(static_cast<unsigned int>(timeout_seconds)); |
| 99 | printf("Runner watchdog enabled (%.1f seconds)\n", timeout_seconds); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | static void cancel() FL_NOEXCEPT { |
| 104 | if (!g_active) { |