MCPcopy Create free account
hub / github.com/ioi/isolate / read_proc_file

Function read_proc_file

isolate.c:491–513  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

489
490#define PROC_BUF_SIZE 4096
491static int
492read_proc_file(char *buf, char *name, int *fdp)
493{
494 int c;
495
496 if (*fdp < 0)
497 {
498 snprintf(buf, PROC_BUF_SIZE, "/proc/%d/%s", (int) box_pid, name);
499 *fdp = open(buf, O_RDONLY);
500 if (*fdp < 0)
501 return 0; // This is OK, the process could have finished
502 }
503 lseek(*fdp, 0, SEEK_SET);
504 if ((c = read(*fdp, buf, PROC_BUF_SIZE-1)) < 0)
505 {
506 // Even this could fail if the process disappeared since open()
507 return 0;
508 }
509 if (c >= PROC_BUF_SIZE-1)
510 die("/proc/$pid/%s too long", name);
511 buf[c] = 0;
512 return 1;
513}
514
515static int
516get_wall_time_ms(void)

Callers 1

get_run_time_msFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…