| 87 | } |
| 88 | |
| 89 | void end_crash_dump() { |
| 90 | fflush(stdout); |
| 91 | if (saved_stdout_fd >= 0) { |
| 92 | _dup2(saved_stdout_fd, _fileno(stdout)); |
| 93 | _close(saved_stdout_fd); |
| 94 | saved_stdout_fd = -1; |
| 95 | } |
| 96 | if (crash_dump_fd >= 0) { |
| 97 | _close(crash_dump_fd); |
| 98 | crash_dump_fd = -1; |
| 99 | } |
| 100 | // Now stdout is back to console - print the dump to console too |
| 101 | FILE* dump = fopen(crash_dump_path, "r"); |
| 102 | if (dump) { |
| 103 | char buf[512]; |
| 104 | while (fgets(buf, sizeof(buf), dump)) { |
| 105 | fputs(buf, stdout); |
| 106 | } |
| 107 | fclose(dump); |
| 108 | } |
| 109 | // Print marker so AI agents / test harness can find the dump |
| 110 | printf("\n[CRASH_DUMP_FILE: %s]\n", crash_dump_path); |
| 111 | fflush(stdout); |
| 112 | } |
| 113 | |
| 114 | // --- Symbol helpers --- |
| 115 |
no test coverage detected