delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/03/11/14:34:53

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
Date: Thu, 11 Mar 2004 14:34:32 -0500
From: Christopher Faylor <cgf-no-personal-reply-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Win32 Redirect stdIn stdErr in same process
Message-ID: <20040311193432.GA13384@redhat.com>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <p06020404bc75ccd0e1df@[217.146.68.221]>
Mime-Version: 1.0
In-Reply-To: <p06020404bc75ccd0e1df@[217.146.68.221]>
User-Agent: Mutt/1.4.1i
Reply-To: cygwin AT cygwin DOT com

On Thu, Mar 11, 2004 at 09:01:56AM +0100, Valerio Ferrucci wrote:
>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 stdIn 
>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?

On cygwin you'd do just what you mention above.

Using the Win32 API, you'd find a mailing list or newsgroup which was
devoted to this sort of thing and ask there.  The cygwin mailing list is
not the place for this kind of win32 question.  The whole point of cygwin
is that it provides a UNIX-like way of doing things to avoid these kind
of win32 considerations.

--
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