| 770 | } |
| 771 | |
| 772 | static bool watcher_windows_wait_pid(const char *marker, uint64_t deadline_ms, |
| 773 | uint64_t *process_id_out) { |
| 774 | if (process_id_out) { |
| 775 | *process_id_out = 0; |
| 776 | } |
| 777 | while (cbm_now_ms() < deadline_ms) { |
| 778 | FILE *file = cbm_fopen(marker, "rb"); |
| 779 | unsigned long long parsed = 0; |
| 780 | bool valid = file && fscanf(file, "%llu", &parsed) == 1 && parsed > 1 && |
| 781 | parsed <= MAXDWORD && parsed != (unsigned long long)GetCurrentProcessId(); |
| 782 | if (file) { |
| 783 | (void)fclose(file); |
| 784 | } |
| 785 | if (valid) { |
| 786 | if (process_id_out) { |
| 787 | *process_id_out = (uint64_t)parsed; |
| 788 | } |
| 789 | return true; |
| 790 | } |
| 791 | cbm_usleep(1000); |
| 792 | } |
| 793 | return false; |
| 794 | } |
| 795 | |
| 796 | static HANDLE watcher_windows_open_exact_process(uint64_t process_id, |
| 797 | const watcher_windows_image_identity_t *expected) { |
no test coverage detected