Linux system("top -p pid") command in program

view full story

http://stackoverflow.com – I have a Linux program that is interspersed with calls to the system API, specifically system("top"), so I can monitor virtual memory at various points in the program. I print the memory stats 4 times, as well as attempting to print other data in between these calls. However, when my program is complete, it looks as if the top command is refreshing the page, so the other data I need to print is being obliterated. I tried to add a number of iterations, as in, system("top -p pid -n 1) but I had the same problems. Is there a way to have a call to top in Linux not refresh the output buffer? I do (HowTos)