I've got a problem with the CreateProcess() function - it seems
to allocate a second threadhandle on some versions of Windows.
My application periodically launches child applications and waits
for their termination.
On my development machine (NT Server, SP6), there's no problem,
but on the test machines (NT Workstation, SP6 and W2K Professional),
the handle count of the parent application increases each time a child
is created/terminated.
Using sysinternals process explorer, I found the following:
When CreateProcess is called, a thread- and a process-handle is created.
This is what happens on the NT server machine - on the other machines,
there is an additional threadhandle created, which cannot be closed,
because there's no way to get it returned. :(
(See the code for the test program below)
Has anyone seen this problem before?
Can anyone give me a hint how to aviod the creation of the third handle
or how to close this handle?
Thanks in advance,
Jörg
--------------------------- BEGIN SOURCE ------------------------
#include <windows.h>
#include <stdio.h>
static int wait()
{
int c;
printf("\n ... press ENTER ...\n");
fflush(stdout);
c = getc(stdin);
return(c);
}
int main (int argc, const char *argv[], const char *env[])
{
char *pcPrg = "ipconfig.exe";
for (;;)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
printf("going to start child");
wait();
// Start the child process.
if( !CreateProcess( NULL,
pcPrg, // call ipconfig
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi )
)
{
printf( "CreateProcess failed.\n" ); exit(1);
}
printf("child started"); wait();
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
printf("child terminated, cleaned up"); wait();
}
return(0);
}
--------------------------- END SOURCE ------------------------
The only thing I can suggest is if your processes are console mode
processes, you may have to specify some of the special creation flags
specified in the documentation.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/process_creation_flags.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createprocess.asp
Shailesh
I found the problem-source: it's the "IBM Tivoli License Manager" service,
when this service is stopped, the problem doesn't occur any more :-)
Jörg
Shailesh Humbad <humb...@hotmail.com> wrote in message news:<Gzbqa.158434$0X.34...@twister.columbus.rr.com>...