stderr output when using popen in C++ linux -


when use simple program standard output of process, somehow standard error of process, although man page popen says standard output redirected. possible related shell used when forking process popen? errer simple program outputting stderr (cerr << "hello";). i'm using rhel 6.4. thanks!

#include <iostream> #include <cstdio>  using namespace std;  int main () {     file *fd = popen("errwr", "r");     char str [1024];     while (fgets(str, 1024, fd))     {         cout<<str<<endl;     }     return 0; } 

you're not getting output stderr in program using popen.

following simple example shows, error stream started application printed in terminal, without being read in program. popen redirects stdout stream , stderr stream not affected, it's printed terminal.

#include <iostream> #include <cstdio>  using namespace std;  int main () {     file *fd = popen("errwr", "r");     char str [1024];     while (fgets(str, 1024, fd))     {         cout << "=>" << str << "<=" << endl;     }     return 0; } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -