Is there a way of getting the process id of my C++ application?
-
09-06-2019 - |
Question
Is there a way of getting the process id of my C++ application? I am using the Carbon framework, but not Cocoa…
Solution
can you use the getpid() function found in unistd.h ?
OTHER TIPS
GetProcessPID is what you need. This takes a ProcessSerialNumber, which you can obtain from GetCurrentProcess.
Note that you don't actually need to call GetCurrentProcess, you can use the constant kCurrentProcess.
(But getpid is a lot less work if you're not trying to access another process's PID, anyway.)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow