【发布时间】:2015-03-02 17:15:39
【问题描述】:
我有一个使用popen 解析命令行输出的应用程序。但是,在 Android 上测试时,它在pclose 上崩溃:为什么?在其他 Unix 环境中测试时,我没有错误...
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 会导致我的应用程序在稍后阶段崩溃,就好像执行此调用会杀死我的应用程序一样。
【问题讨论】:
-
@Gopi 感谢您的提示,请检查更新...
标签: android c linux file-io pipe