PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, October 7, 2022

[FIXED] How to see contents of /proc/[pid]/status after process finishes execution?

 October 07, 2022     linux, performance, process, statistics     No comments   

Issue

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?


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.



Answered By - lunixbochs
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing