This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Win32 Redirect stdOut stdErr in same process


On Thu, 11 Mar 2004, Valerio Ferrucci wrote:

> Errata corrige: in my previous mail I wrote stdIn where I wanted to mean stdOut
>
> Hi,
> I hope that someone on the list can help me about this or point me to
> some docs or example.
> My Win32 application calls an external library that writes to stdOut
> and stdErr. I want to capture (redirect) these outputs (in order to
> send them back to the user via http). Note that I can't spawn another
> process because the library must run in the same process context of
> the caller.
>
> On Unix my code is very simple:
>
> int     fdOut[2]={-1, -1};
> pipe(fdOut)
> dup2(fdOut[1], STDOUT_FILENO)
> ... call the library
> fcntl(fdOut[0], F_SETFL, fileFlags | O_NONBLOCK)
> ... read from fdOut[0]
>
> Any idea on how to do this using Win32 API?
> Any working example?
> Thanks for help

Valerio,

The above Unix code should work OOTB on Cygwin.  Just compile it and run
it.  Note that you'll require at least cygwin1.dll to run the application.

If you're asking how to do this *without* Cygwin, then this is off-topic
for this list, and you should ask somewhere else (e.g., on a Win32 list or
forum).  Just to give you a hint, the code above may still work OOTB with
MinGW (see <http://mingw.org/> for project and contact information).
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]