Skip to content

Commit efa4fcb

Browse files
committed
fix: CI test failures - headless stdin EOF handling on Linux and Windows, WM_APP_REQUEST_CLOSE handling on Windows
1 parent 8c97877 commit efa4fcb

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

plug.app/src/linux/api/intf/main_l.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,9 +690,10 @@ void main_l_cleanup(void) {
690690
if (g_cmd_thread.joinable()) {
691691
g_cmd_thread.join();
692692
}
693-
// stdin worker blocks on getline; detach so it doesn't prevent exit
693+
// stdin worker blocks on getline; close stdin to unblock it, then join
694694
if (g_headless_stdin_thread.joinable()) {
695-
g_headless_stdin_thread.detach();
695+
fclose(stdin);
696+
g_headless_stdin_thread.join();
696697
}
697698
if (g_app) {
698699
g_object_unref(g_app);

plug.app/src/windows/api/intf/main_w.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,11 @@ static LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
633633
std::cout << "---STATE_DUMP_END---\n" << std::endl;
634634
return 0;
635635
}
636+
case WM_APP_REQUEST_CLOSE: { // WM_APP_REQUEST_CLOSE
637+
g_running_ui = false;
638+
DestroyWindow(hwnd);
639+
return 0;
640+
}
636641
#endif
637642
case WM_APP + 100: {
638643
std::lock_guard<std::mutex> lk(g_mutex);
@@ -1201,6 +1206,14 @@ static LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
12011206
caret_cleanup();
12021207
PostQuitMessage(0);
12031208
break;
1209+
#ifdef PLUG_ENABLE_HEADLESS_MODE
1210+
case WM_APP_REQUEST_CLOSE:
1211+
if (g_hwnd) {
1212+
g_running_ui = false;
1213+
DestroyWindow(g_hwnd);
1214+
}
1215+
break;
1216+
#endif
12041217
default:
12051218
return DefWindowProc(hwnd, msg, wParam, lParam);
12061219
}
@@ -1286,7 +1299,9 @@ extern "C" void main_w_cleanup(void) {
12861299

12871300
#ifdef PLUG_ENABLE_HEADLESS_MODE
12881301
if (g_headless_stdin_thread.joinable()) {
1289-
g_headless_stdin_thread.detach();
1302+
// Close stdin to unblock getline() in headless_stdin_worker
1303+
fclose(stdin);
1304+
g_headless_stdin_thread.join();
12901305
}
12911306
#endif
12921307
}

0 commit comments

Comments
 (0)