Linux/C/管道:
我如何使用popen(或类似的系统调用)捕获ping命令的输出。目前,popen将等待ping命令完成,然后一起输出。
伪代码:
fp= popen("ping x.x.x.x", "r");
while(!feof(pFp))
{
if(fgets(fp ...) // <==currently the code blocks here until ping finishes in popen
{
printf(...real time ping output here);
}
}