| 14 | static const char* report_path; |
| 15 | |
| 16 | static void* worker(void* arg) { |
| 17 | (void)arg; |
| 18 | |
| 19 | pid_t pid = fork(); |
| 20 | if (pid < 0) { |
| 21 | _exit(1); |
| 22 | } |
| 23 | if (pid == 0) { |
| 24 | size_t region = 64UL * 1024 * 1024; |
| 25 | void* mem = mmap(NULL, region, PROT_READ | PROT_WRITE, |
| 26 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
| 27 | if (mem == MAP_FAILED) { |
| 28 | _exit(1); |
| 29 | } |
| 30 | memset(mem, 0x42, region); |
| 31 | |
| 32 | int ret = write_rss_report(report_path); |
| 33 | munmap(mem, region); |
| 34 | _exit(ret); |
| 35 | } |
| 36 | |
| 37 | int status; |
| 38 | if (waitpid(pid, &status, 0) < 0 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) { |
| 39 | _exit(1); |
| 40 | } |
| 41 | return NULL; |
| 42 | } |
| 43 | |
| 44 | int main(int argc, char** argv) { |
| 45 | if (argc != 2) { |
nothing calls this directly
no test coverage detected