| 120 | |
| 121 | |
| 122 | void StopControl() { |
| 123 | LOG_W(LOG_INFO, L"Control: Stop Thread"); |
| 124 | |
| 125 | // Signal the thread to stop |
| 126 | keep_running = FALSE; |
| 127 | |
| 128 | // Send empty data to unblock any pending pipe operations |
| 129 | pipeServer.Send((char*)""); |
| 130 | |
| 131 | // Wait for the thread to finish (with timeout) |
| 132 | if (control_thread != NULL) { |
| 133 | DWORD waitResult = WaitForSingleObject(control_thread, 5000); // 5 second timeout |
| 134 | if (waitResult == WAIT_TIMEOUT) { |
| 135 | LOG_W(LOG_ERROR, L"Control: Thread did not stop gracefully, terminating"); |
| 136 | TerminateThread(control_thread, 1); |
| 137 | } |
| 138 | CloseHandle(control_thread); |
| 139 | control_thread = NULL; |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | |
| 144 | ////// |
no test coverage detected