delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/10/02/11:41:34

From: sos AT prospect DOT com DOT ru (Sergey Okhapkin)
Subject: RE: Right way in Win32 to redirect child process stdout?
2 Oct 1998 11:41:34 -0700 :
Message-ID: <01BDEDE1.D57C9CA0.cygnus.gnu-win32@sos>
To: "gnu-win32 AT cygnus DOT com" <gnu-win32 AT cygnus DOT com>,
"'Igor boukanov'"
<boukanov AT fi DOT uib DOT no>

Igor boukanov wrote:
> HANDLE old = GetStdHandle(STD_OUTPUT_HANDLE);
> SetStdHandle(STD_OUTPUT_HANDLE, redirection_handle);
> CreateProcess(...);
> SetStdHandle(STD_OUTPUT_HANDLE, old);
> ..
>
> does not work in multithreading program because there is a chance that 
some thread will write to stdout between SetStdHandle and CreateProcess
> spoiling child output to redirection_handle.

> But maybe there is a truly robust way to do that?
>

Do not set stdout of parent, but set child's stdout to redirection_handle 
with StartupInfo structure passed to CreateProcess() call.

--
Sergey Okhapkin, http://www.lexa.ru/sos
Moscow, Russia


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


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