title: Linux system("top -p pid") command in program
body: <p>I have a Linux program that is interspersed with calls to the system API, specifically <code>system("top")</code>, 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.</p>
  
  <p>However, when my program is complete, it looks as if the <code>top</code> 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, <code>system("top -p pid -n 1)</code> but I had the same problems.</p>
  
  <p>Is there a way to have a call to <code>top</code> in Linux not refresh the output buffer? I don't know where else to turn. Thanks!</p>