How to see contents of /proc/[pid]/status after process finishes execution?
linux, performance, process, statistics
Solution
Tossing this `system()` call at the end of your program will print `/proc/[pid]/status` to stdout at the very last moment before your program quits.
#include <stdlib.h>
int main() {
system("cat /proc/$PPID/status");
return 0;
}
+1 for external programs like `valgrind`. You can trap your program's exit with debugging utils and check complete statistics without modifying the program.
Problem
I want to see statistics of a small C program, but is a small program that begins and ends. (Not some program that is long time running). I want to improve this program in terms of access to memory, cache hits, context switches, and that sort of things. The parameters in `/proc/[pid]/status` are great, but I cannot find the way to see them after execution. How can I see this file after the proccess has finished execution?