Getting the PID from system() or popen()

Discussion in 'Mac Programming' started by Blarged, Jun 18, 2008.

  1. Blarged
    Expand Collapse
    macrumors newbie

    Apr 14, 2008
    Ok, this seems elementary to me, but I can't for the life of me figure it out.

    I need to launch an app from my c++ app. But I need to know the PID. Am I able to find this out from system() or popen()?

    If I remember right, when you fork a process, the pid return value for the parent process is actual value of the child pid process, is that a way I could tackle this?
  2. aaronw1986
    Expand Collapse
    macrumors 68030

    Oct 31, 2006
    Are you forking the process you want to open? If so, then yes, you can keep track when you fork.
  3. Blarged
    Expand Collapse
    thread starter macrumors newbie

    Apr 14, 2008
    I am not using a fork() call specifically. Currently I am just using system() which in itself uses fork().
  4. HiRez
    Expand Collapse
    macrumors 603


    Jan 6, 2004
    Western US
    Wow, that's kind of a personal question. Isn't there a Hot Chat forum on MacRumors?

Share This Page