From 184669188717673c4cb36698192fe8c14aa3af68 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 21 Dec 2009 17:56:32 +0000 Subject: Ok, Process has been updated. You now must specify flags as the first parameter of both constructors, this allows you to control which streams to bind to. To preserve the old behaviour, simply put Bu::Process::StdOut before your old first parameters. --- src/tests/procs.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src/tests') diff --git a/src/tests/procs.cpp b/src/tests/procs.cpp index 4f177c9..d914324 100644 --- a/src/tests/procs.cpp +++ b/src/tests/procs.cpp @@ -11,21 +11,25 @@ int main() { - //Bu::Process p( argv[1], argv+1 ); - Bu::Process p("mplayer", "mplayer", "dvd://", "-framedrop", - "-ao", "null", "-nosound", "-vf", "framestep=I,cropdetect", "-sstep", - "197", NULL ); + Bu::Process p( Bu::Process::Both, "/bin/bash", "/bin/bash", "-c", "echo Hello 1>&2; echo StdOut; sleep 1; echo Yup; echo Yup 1>&2", NULL ); char buf[1000]; - for(;;) + while( !p.isEos() ) { - int iSize = p.read( buf, 1000 ); - printf("::read=%d::\n", iSize ); - if( iSize == 0 ) - break; - fwrite( buf, iSize, 1, stdout ); - if( iSize < 1000 ) - break; + bool out, err; + p.select( out, err ); + if( out ) + { + int iSize = p.read( buf, 1000 ); + printf("::read=%d::\n", iSize ); + fwrite( buf, iSize, 1, stdout ); + } + if( err ) + { + int iSize = p.readErr( buf, 1000 ); + printf("::readErr=%d::\n", iSize ); + fwrite( buf, iSize, 1, stdout ); + } } return 0; -- cgit v1.2.3