你怎么知道 popen()
是成功/完成运行 shell 还是失败?
最佳答案
Upon successful completion, popen() shall return a pointer to an open stream that can be used to read or write to the pipe. Otherwise, it shall return a null pointer and may set errno to indicate the error.
fp = popen("ls *", "r");
if (fp == NULL)
/* Handle error */;
关于c++ - 如何判断 popen() 是否成功?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8582142/