I'm trying to write an iphone app that would mimic the top system utility available on *nix systems. It seems as if system() and/or popen() should enable me to capture output from system commands executed on the iphone. However, the following code gives no output for either popen or system. Is there some other way of getting this info. The iStats app on the iphone seems to be able to capture this and I'm assuming its blessed by Apple since its in the app store. In any event any help would be very much appreciated!!
FILE *f = popen("ps", "r");
StringPtr *buf1 = malloc(60);
fread(buf1, 0, sizeof(buf1), f);
NSLog(@"system = %s",buf1 );
system('ls /');