0
我有一個應用程序使用popen
解析命令行的輸出。但是,在Android上進行測試時,它在pclose
上崩潰:爲什麼?當其他的Unix環境中測試我有沒有錯誤...pclose上的應用程序崩潰
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;
更新:看來,使用popen
導致我的應用程序反正崩潰,在以後的階段,如果這樣調用殺死我的應用程序。
http://stackoverflow.com/questions/5431941/while-feof-file-is-always-wrong – Gopi 2015-03-02 17:21:21
@戈皮感謝您的提示,請檢查更新... – Antonio 2015-03-02 18:06:24