MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / worker

Function worker

crates/memtrack/testdata/rss/rmap_thread_fork.c:16–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14static const char* report_path;
15
16static 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
44int main(int argc, char** argv) {
45 if (argc != 2) {

Callers

nothing calls this directly

Calls 1

write_rss_reportFunction · 0.85

Tested by

no test coverage detected