| 1026 | } |
| 1027 | |
| 1028 | static bool watcher_test_self_image(char out[CBM_SZ_4K]) { |
| 1029 | #ifdef __APPLE__ |
| 1030 | int length = proc_pidpath(getpid(), out, CBM_SZ_4K); |
| 1031 | if (length <= 0 || length >= CBM_SZ_4K) { |
| 1032 | return false; |
| 1033 | } |
| 1034 | out[length] = '\0'; |
| 1035 | return true; |
| 1036 | #else |
| 1037 | ssize_t length = readlink("/proc/self/exe", out, CBM_SZ_4K - 1); |
| 1038 | if (length <= 0 || length >= CBM_SZ_4K - 1) { |
| 1039 | return false; |
| 1040 | } |
| 1041 | out[length] = '\0'; |
| 1042 | return true; |
| 1043 | #endif |
| 1044 | } |
| 1045 | |
| 1046 | static bool watcher_test_wait_pid(const char *marker, uint64_t deadline_ms, pid_t *pid_out) { |
| 1047 | while (cbm_now_ms() < deadline_ms) { |