Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CreateProcess and process groups

CreateProcess and process groups

Scheduled Pinned Locked Moved C / C++ / MFC
linuxquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ionzarate
    wrote on last edited by
    #1

    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!. :)

    B 1 Reply Last reply
    0
    • I ionzarate

      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!. :)

      B Offline
      B Offline
      Blake Miller
      wrote on last edited by
      #2

      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."

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups