[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Why cann't capture the stdout
- From: "Matthew Wild" <mwild1@...>
- Date: Sun, 26 Oct 2008 14:10:00 +0100
2008/10/26 Andy.Tao <taozuhong@qq.com>:
> Hi gus,
>
> I have meet a trouble, does anyone could help me?
>
> I embeded lua in my MFC program, and create pipe to receive lua stdout text,
> it can receive error message but print, why? code context is:
>
> 1. Create Pipe: CreatePipe(&PipeRead, &PipeWrite, NULL, 0)
> 2. Assign pipe write handle to stdout and stderr:
> _dup2(_open_osfhandle(PipeRead, _O_TEXT), 1)
> _dup2(_open_osfhandle(PipeRead, _O_TEXT), 2)
> 3. Create thread to read pipe read handle
> 4. Execute lua code which contain statement: print and error
> 5. It can receive statement(error) message but print
>
> thanks in advanced!
>
Just a shot in the dark, as it has been way too long (or not long
enough) since I worked on Windows. But:
> _dup2(_open_osfhandle(PipeRead, _O_TEXT), 1)
> _dup2(_open_osfhandle(PipeRead, _O_TEXT), 2)
Shouldn't one of these be write, rather than read?
Matthew.