1

Is there an API in the C++ (or STL) to fetch the parent process id? if not then what could be the portable code to do so? I understand there linux api such as getppid can do the job on unix platforms but what is equivalent of the same on windows?

Thanks!

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Rohit
  • 155
  • 1
  • 2
  • 8
  • 1
    Libraries such as Qt and boost can achieve your goal in a cross-platform manner. In the boost case, here is information about the process class: http://www.highscore.de/boost/process/reference/classboost_1_1process_1_1process.html – Didac Perez Parera Aug 23 '13 at 11:30
  • 1
    However, Boost.Process is not (yet) an official Boost C++ library. – HAL Aug 23 '13 at 12:25

1 Answers1

6

Following links will hep you

http://www.codeproject.com/Articles/9893/Get-Parent-Process-PID

https://gist.github.com/253013/d47b90159cf8ffa4d92448614b748aa1d235ebe4

asit_dhal
  • 1,239
  • 19
  • 35
  • Thanks Phoenix, it worked! However I was curious to know this code would work on the Windows64 as well? – Rohit Aug 23 '13 at 17:29
  • change the build configuration to 64 bit(default is all computers) and check if it builds successfully. – asit_dhal Aug 23 '13 at 21:46