| 656 | } |
| 657 | |
| 658 | static bool readProcessIO(int pid, ProcessInfo* info) { |
| 659 | char path[64]; |
| 660 | snprintf(path, sizeof(path), "/proc/%d/io", pid); |
| 661 | FILE* file = fopen(path, "r"); |
| 662 | if (!file) return false; |
| 663 | |
| 664 | int read_count = 0; |
| 665 | char line[1024]; |
| 666 | while (fgets(line, sizeof(line), file) && read_count < 2) { |
| 667 | if (strncmp(line, "read_bytes:", 11) == 0) { |
| 668 | u64 read_bytes = strtoull(line + 11, NULL, 10); |
| 669 | info->io_read = read_bytes >> 10; |
| 670 | read_count++; |
| 671 | } else if (strncmp(line, "write_bytes:", 12) == 0) { |
| 672 | u64 write_bytes = strtoull(line + 12, NULL, 10); |
| 673 | info->io_write = write_bytes >> 10; |
| 674 | read_count++; |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | fclose(file); |
| 679 | return true; |
| 680 | } |
| 681 | |
| 682 | bool OS::getBasicProcessInfo(int pid, ProcessInfo* info) { |
| 683 | return readProcessStats(pid, info); |
no outgoing calls
no test coverage detected