| 489 | |
| 490 | #define PROC_BUF_SIZE 4096 |
| 491 | static int |
| 492 | read_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 | |
| 515 | static int |
| 516 | get_wall_time_ms(void) |
no outgoing calls
no test coverage detected
searching dependent graphs…