when I use this simple program to get the standard output of the process, I also somehow get the standard error of the process, although the man page for popen
says that only the standard output is redirected. Is it possible that this is related to the shell that is used when forking a process with popen
? errEr
is a simple program outputting to 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;
}