I have an application that parses the output from a command line using popen
. However, when tested on Android, it crashes on pclose
: Why? When tested in other Unix environment I have no error...
char commandLine[256] = "ps -A | grep -c myApplication";
FILE * fPipe = popen(commandLine, "r");
if (fPipe == NULL)
return 0;
int count = -1;
fscanf(fPipe, "%d", &count);
///If here I print count, I get zero, which is correct...
pclose(fPipe); ///Here it crashes!
return count;
Update: It seems that using popen
causes my application to crash anyway, at a later as stage, as if doing this call kills my application.