| 614 | } |
| 615 | |
| 616 | static bool readProcessStatus(int pid, ProcessInfo* info) { |
| 617 | char path[64]; |
| 618 | snprintf(path, sizeof(path), "/proc/%d/status", pid); |
| 619 | FILE* file = fopen(path, "r"); |
| 620 | if (!file) { |
| 621 | return false; |
| 622 | } |
| 623 | |
| 624 | int read_count = 0; |
| 625 | char line[1024]; |
| 626 | char key[32]; |
| 627 | u64 value; |
| 628 | while (fgets(line, sizeof(line), file) && read_count < 6) { |
| 629 | if (sscanf(line, "%31s %llu", key, &value) != 2) { |
| 630 | continue; |
| 631 | } |
| 632 | |
| 633 | if (strncmp(key, "Uid", 3) == 0) { |
| 634 | read_count++; |
| 635 | info->uid = (unsigned int)value; |
| 636 | } else if (strncmp(key, "RssAnon", 7) == 0) { |
| 637 | read_count++; |
| 638 | info->rss_anon = value * 1024; |
| 639 | } else if (strncmp(key, "RssFile", 7) == 0) { |
| 640 | read_count++; |
| 641 | info->rss_files = value * 1024; |
| 642 | } else if (strncmp(key, "RssShmem", 8) == 0) { |
| 643 | read_count++; |
| 644 | info->rss_shmem = value * 1024; |
| 645 | } else if (strncmp(key, "VmSize", 6) == 0) { |
| 646 | read_count++; |
| 647 | info->vm_size = value * 1024; |
| 648 | } else if (strncmp(key, "VmRSS", 5) == 0) { |
| 649 | read_count++; |
| 650 | info->vm_rss = value * 1024; |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | fclose(file); |
| 655 | return true; |
| 656 | } |
| 657 | |
| 658 | static bool readProcessIO(int pid, ProcessInfo* info) { |
| 659 | char path[64]; |
no outgoing calls
no test coverage detected