CreateProcess and process groups
-
Hello everybody! I´m using CreateProcess to create a new process, with the CREATE_NEW_PROCESS_GROUP flag set in the argument "dwCreationFlags", to create a new process group. Let´s call PROCESS_A the one which calls CreateProcess, and PROCESS_B the one which is created. MSDN says in "CreateProcess" function: ------------------------------------------------------ CREATE_NEW_PROCESS_GROUP: The new process is the root process of a new process group. The process group includes all processes that are descendants of this root process. The process identifier of the new process group is the same as the process identifier, which is returned in the lpProcessInformation parameter. Process groups are used by the GenerateConsoleCtrlEvent function to enable sending a ctrl+c or ctrl+break signal to a group of console processes. ------------------------------------------------------ I know that from PROCESS_A, I can get the PID of the PROCESS_B through "lpProcessInformation", which is also the identifier of the new process group. I also know that "GetCurrentProcessID" returns the PID of the current process. But I need that PROCESS_B knows the ID of its own process group, without having to pass it in the command line arguments, when CreateProcess is called. -Is it possible to get the ID of a process group? -How can PROCESS_B know the identifier of its own process group? (without passing it in the command line when CreateProcess is called) -Is there any function which returns process group ID of the calling process, like "getpgid(0)" in Linux does? Thanks all!. :)
-
Hello everybody! I´m using CreateProcess to create a new process, with the CREATE_NEW_PROCESS_GROUP flag set in the argument "dwCreationFlags", to create a new process group. Let´s call PROCESS_A the one which calls CreateProcess, and PROCESS_B the one which is created. MSDN says in "CreateProcess" function: ------------------------------------------------------ CREATE_NEW_PROCESS_GROUP: The new process is the root process of a new process group. The process group includes all processes that are descendants of this root process. The process identifier of the new process group is the same as the process identifier, which is returned in the lpProcessInformation parameter. Process groups are used by the GenerateConsoleCtrlEvent function to enable sending a ctrl+c or ctrl+break signal to a group of console processes. ------------------------------------------------------ I know that from PROCESS_A, I can get the PID of the PROCESS_B through "lpProcessInformation", which is also the identifier of the new process group. I also know that "GetCurrentProcessID" returns the PID of the current process. But I need that PROCESS_B knows the ID of its own process group, without having to pass it in the command line arguments, when CreateProcess is called. -Is it possible to get the ID of a process group? -How can PROCESS_B know the identifier of its own process group? (without passing it in the command line when CreateProcess is called) -Is there any function which returns process group ID of the calling process, like "getpgid(0)" in Linux does? Thanks all!. :)
Maybe I am not reading this correctly, but isn't this already your answer?
I know that from PROCESS_A, I can get the PID of the PROCESS_B through
"lpProcessInformation", which is also the identifier of the new process
group.If the PROCESS GROUP ID is the same as the PROCESS ID for your ProcessB, then from within the ProcessB, just call GetProcessID() and that should match the process group identifier. Doesn't your statement above imply the new process group id is the same as the processB process identifier :confused: MSND says same thing:
"The process identifier of the new process group is the same as the process identifier, which is returned in the lpProcessInformation parameter."