Fix printing format in a pretty way

This patch improve the way that psstop prints the results:

Process Name         PID   : Size in KB

[...]

systemd-udevd        23356 : 0      Kb
systemd              24050 : 2183   Kb
(sd-pam)             24051 : 0      Kb
tmux: server         31523 : 1087   Kb
bash                 31524 : 4      Kb
bash                 31525 : 4      Kb
vim                  31684 : 4      Kb

Total is 19871Kb (181 processes)

Signed-off-by: Victor Rodriguez <victor.rodriguez.bahena@intel.com>
This commit is contained in:
Victor Rodriguez
2016-12-01 23:02:43 +00:00
parent 4567cc55a7
commit 5a8a6d70c0
+4 -2
View File
@@ -84,7 +84,7 @@ static void do_one_process(int pid)
fclose(file);
}
printf("%" PRIu64 " Kb: %s (%i) \n", process.PSS_kb, process.name, pid);
printf("%-20s %-5i : %-5" PRIu64 " Kb\n",process.name, pid , process.PSS_kb);
total_PSS += process.PSS_kb;
total_proc++;
free(process.name);
@@ -100,6 +100,8 @@ int main(int argc, char **argv)
}
dir = opendir("/proc");
printf("\n%-20s %-5s : %-5s \n\n","Process Name", "PID", "Size in KB");
while (dir) {
int pid;
entry = readdir(dir);
@@ -111,7 +113,7 @@ int main(int argc, char **argv)
do_one_process(pid);
}
printf("Total is %" PRIu64 "Kb (%i processes)\n", total_PSS, total_proc);
printf("\nTotal is %" PRIu64 "Kb (%i processes)\n", total_PSS, total_proc);
closedir(dir);
free(searchkey);
return EXIT_SUCCESS;