| 993 | } |
| 994 | |
| 995 | static bool watcher_windows_terminate_verified(HANDLE process, |
| 996 | const watcher_windows_image_identity_t *expected, |
| 997 | uint64_t deadline_ms) { |
| 998 | if (!process) { |
| 999 | return false; |
| 1000 | } |
| 1001 | if (WaitForSingleObject(process, 0U) == WAIT_OBJECT_0) { |
| 1002 | return true; |
| 1003 | } |
| 1004 | /* Re-query the live process image immediately before the only test-side |
| 1005 | * kill. The retained handle fixes the process instance; canonical path and |
| 1006 | * file identity ensure a cleanup backstop can target only our private copy. */ |
| 1007 | if (!watcher_windows_process_matches_image(process, expected) || |
| 1008 | TerminateProcess(process, 99U) == 0) { |
| 1009 | return false; |
| 1010 | } |
| 1011 | return watcher_windows_wait_process_gone(process, deadline_ms); |
| 1012 | } |
| 1013 | #endif |
| 1014 | |
| 1015 | #if defined(__APPLE__) || defined(__linux__) |
no test coverage detected