CreateProcess not collecting Std Out from Process's children.

Hi All,
I've been working on creating a program that automates my program building and testing. A portion that I'm having issues on is collecting the stdout and stderr on process's children processes.
I've attached a portion of *sample* code that I'm working on trying to perfect so that I can incorporate it back in to my program. I've tried taking care of security access issues (possibly a reason that the stdout handle isn't being inhereted by children process's) by using the Security Descriptor. Also, I have tried to duplicate the pipe write handle, in hopes that would solve the problem. And I've varied my flags for creation (in CreateProcess) using CREATE_NEW_CONSOLE, CREATE_PRESERVE_CODE_AUTHZ_LEVEL, DETACHED_PROCESS. Nothing seems to work.

Please, please help me.

I have attached my process creation code, and my output that I'm getting. **The output is ALWAYS the same, no matter what variations I put in to my code. And if you look at the spew at the bottom, you'll see I always get up to "Linking..." and then nothing more.
/****************** Begin Code ********************/
BOOL bSuccess;
STARTUPINFO si;
PROCESS_INFORMATION pi;
SECURITY_ATTRIBUTES saPipe;
SECURITY_DESCRIPTOR sd;

HANDLE hOutRead, hOutWrite, hInRead, hInWrite, hErrRead, hErrWrite;
hOutRead = hOutWrite = hInRead = hInWrite = hErrRead = hErrWrite = 0;


ZeroMemory( &si, sizeof(STARTUPINFO) );
ZeroMemory( &pi, sizeof(PROCESS_INFORMATION) );
InitializeSecurityDescriptor( &sd, SECURITY_DESCRIPTOR_REVISION);
bSuccess = SetSecurityDescriptorDacl( &sd, true, NULL, false );


saPipe.bInheritHandle = TRUE;
saPipe.lpSecurityDescriptor = &sd;
saPipe.nLength = sizeof(SECURITY_ATTRIBUTES);

CreatePipe( &hOutRead, &hOutWrite, &saPipe, 0 );
CreatePipe( &hInRead, &hInWrite, &saPipe, 0 );
CreatePipe( &hErrRead, &hErrWrite, &saPipe, 0 );

if ( hOutWrite && (hErrWrite && hInRead) )
{
HANDLE hDupOutWrite;

//bSuccess = DuplicateHandle( GetCurrentProcess(), hOutWrite, GetCurrentProcess(), &hDupOutWrite, NULL, TRUE, DUPLICATE_SAME_ACCESS );

si.cb = sizeof( STARTUPINFO );
si.hStdOutput = hOutWrite;
si.hStdInput = hInRead;
si.hStdError = hErrWrite;
si.dwFlags = STARTF_USESTDHANDLES;

//si.dwFlags = CREATE_NO_WINDOW ;

bSuccess = CreateProcess( "c:\\windows\\system32\\cmd.exe",
TEXT("/C devenv.com /rebuild \"Release\" \"c:\\testproject\\testproject.sln\""),
NULL,//&saPipe,
NULL,//&saPipe,
TRUE,
0,
0,
TEXT("c:\\program files\\microsoft visual studio .NET 2003\\common7\\IDE\0"),
&si,&pi );

if ( bSuccess )
{
CreateThread( &saPipe, NULL, ReadStdOutThread, (LPVOID)&g_ThreadParams, NULL, NULL );
}
}
/****************** End Code ****************/
/******** Example Spew collected from StdOut *************/

Microsoft (R) Development Environment Version 7.10.3077.
Copyright (C) Microsoft Corp 1984-2001. All rights reserved.
Rebuild All started: Project: TestProject, Configuration: Release
Deleting intermediate files and output files for project 'TestProject', configuration 'Release'.
Compiling...
stdafx.cpp
Compiling...
TestProject.cpp
Linking...

/************ End Example Spew **********************/

[3509 byte] By [Darren] at [2008-1-21]
# 1
I've added more detail to this question in the c# general forum. I explaing why I'm using this way instead of the .NET equivalent Process.Start(...).

the link is here: http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=98943

Darren at 2007-9-9 > top of Msdn Tech,Software Development for Windows Vista,Windows SDK...
# 2
After examining the output (on suggestion from another programmer) I found that the stream was actually all there, the reason why it wasn't all displayed was because there were NUL ( '\0' ) characters in the stream.

But thanks for taking an interest and reading the post ;-)

Darren at 2007-9-9 > top of Msdn Tech,Software Development for Windows Vista,Windows SDK...

Software Development for Windows Vista

Site Classified