| 932 | } |
| 933 | |
| 934 | static bool watcher_windows_wait_pid(const char *marker, uint64_t deadline_ms, |
| 935 | uint64_t *process_id_out) { |
| 936 | if (process_id_out) { |
| 937 | *process_id_out = 0; |
| 938 | } |
| 939 | while (cbm_now_ms() < deadline_ms) { |
| 940 | FILE *file = cbm_fopen(marker, "rb"); |
| 941 | unsigned long long parsed = 0; |
| 942 | bool valid = file && fscanf(file, "%llu", &parsed) == 1 && parsed > 1 && |
| 943 | parsed <= MAXDWORD && parsed != (unsigned long long)GetCurrentProcessId(); |
| 944 | if (file) { |
| 945 | (void)fclose(file); |
| 946 | } |
| 947 | if (valid) { |
| 948 | if (process_id_out) { |
| 949 | *process_id_out = (uint64_t)parsed; |
| 950 | } |
| 951 | return true; |
| 952 | } |
| 953 | cbm_usleep(1000); |
| 954 | } |
| 955 | return false; |
| 956 | } |
| 957 | |
| 958 | static HANDLE watcher_windows_open_exact_process(uint64_t process_id, |
| 959 | const watcher_windows_image_identity_t *expected) { |
no test coverage detected