delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/03/11/07:26:00

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Thu, 11 Mar 2004 07:25:37 -0500 (EST)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Valerio Ferrucci <valfer AT flashnet DOT it>
cc: cygwin AT cygwin DOT com
Subject: Re: Win32 Redirect stdOut stdErr in same process
In-Reply-To: <p06020406bc75cf677d72@[217.146.68.221]>
Message-ID: <Pine.GSO.4.56.0403110721380.210@slinky.cs.nyu.edu>
References: <p06020406bc75cf677d72@[217.146.68.221]>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.39

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 AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019