PDA

View Full Version : Getting the PID from system() or popen()




Blarged
Jun 18, 2008, 01:11 PM
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?



aaronw1986
Jun 18, 2008, 01:17 PM
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?

Are you forking the process you want to open? If so, then yes, you can keep track when you fork.

Blarged
Jun 18, 2008, 01:18 PM
Are you forking the process you want to open? If so, then yes, you can keep track when you fork.

I am not using a fork() call specifically. Currently I am just using system() which in itself uses fork().

HiRez
Jun 18, 2008, 05:59 PM
Are you forking the process you want to open? If so, then yes, you can keep track when you fork.Wow, that's kind of a personal question. Isn't there a Hot Chat forum on MacRumors?