HELP! popen doesnt get stderr

I’m trying to using popen() to read everything that prints to stdout and
stderr, popen() only handles
stdout and stdin, is there a way to get everything from stderr as well??

Ran Zhang <rzhang@vamcointernational.com> wrote:

I’m trying to using popen() to read everything that prints to stdout and
stderr, popen() only handles
stdout and stdin, is there a way to get everything from stderr as well??

my first thought was:

close( 2 );
dup2( 1, 2 );
popen();

But, not sure if that will work.

You may not be able to use the popen() convenience function, and
may have to manually create the pipes, and spawn the child, setting
the inherited file descriptors directly in the spawn() call.

-David

David Gibbs
QNX Training Services
dagibbs@qnx.com

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:cvgies$hnn$3@inn.qnx.com

Ran Zhang <> rzhang@vamcointernational.com> > wrote:
I’m trying to using popen() to read everything that prints to stdout and
stderr, popen() only handles
stdout and stdin, is there a way to get everything from stderr as well??

my first thought was:

close( 2 );
dup2( 1, 2 );
popen();

But, not sure if that will work.

How about

popen( “blah blah 2>&1”, “r” )