Solaris 中的 popen/pclose 问题
大家好,我希望任何人都可以帮助我。我正在运行一个简单的 C 程序,在 Solaris 8 中运行,并且在使用 popen/pclose 时发现了问题。
文件*流; 流 = popen("ps -ef | grep "模式");
if(pclose(stream)){ printf("流中没有发生错误\n"); 。
grep 命令中的模式只是一个过滤器,我用它来处理较少数量的字符串 当然,在我的代码中,我对返回的流进行了一些处理,但我已经删除了这种处理,并且错误不断发生。
pclose 函数返回错误 256,使用 WIFEXITED 显示这不是命令的异常结束,使用 WSTATUS 显示错误 1,我不知道确切的含义。
显然,当命令返回空字符串或仅包含一行时,就会发生这种情况。
有谁知道这个错误意味着什么?
提前致谢
Hi guys I hope anyone can help me. I'm running a simple program in C, running in Solaris 8, and I found a problem while using popen/pclose.
FILE * stream;
stream = popen("ps -ef | grep "pattern");
if(pclose(stream)){
printf("Erro no fechamento da stream\n");
}
The pattern in grep command it's just a filter that I use to treat a smaller number of strings. Of course in my code I do some treatment on the stream returned, but I've already removed this treatment and the error keep happening.
The pclose function return an error 256, which using WIFEXITED shows that it's not an abnormal ending of the command and using WSTATUS shows an error 1, which I don't know exactly what means.
Apparently this happens when the command returns a string empty or with only one line.
Does anyone have a clue of what this error means?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
man 1 grep
man 1 grep