I am trying to pass a mutex handle to the command line of a child process or in any other way.
How can i do this? How can I use a mutex from a child?
This is how I create the child process:
HANDLE ghMutex; if( !CreateProcess( _T("C:\\Users\\Kumppler\\Documents\\Visual Studio 2010\\Projects\\teste3\\Debug\\teste3.exe"), // No module name (use command line) aux2, // Command line NULL, // Process handle not inheritable NULL, // Thread handle not inheritable TRUE, // Set handle inheritance to TRUE STARTF_USESTDHANDLES, // inherit the standard input, standard output, and standard error handles NULL, // Use parent environment block NULL, // Use parent starting directory &si[j], // Pointer to STARTUPINFO structure &pi[j] ) // Pointer to PROCESS_INFORMATION structure )
EDIT:
I need to use mutexes for more than one child process, ok?
So here is what I am doing right now:
HANDLE ghMutex; int mutex; char mutexstring[7]; mutex=(int)ghMutex; itoa(mutexValue,mutexString,10);
I will pass the mutexString command line and then convert it back to a child process:
mutexValue=atoi(argv[2]); Mutex=(HANDLE)mutexValue;
My question is, is casting (HANDLE) good?
source share