Is there a way of getting the process id of my C++ application?
Asked Answered
G

3

6

Is there a way of getting the process id of my C++ application? I am using the Carbon framework, but not Cocoa…

Gaytan answered 3/9, 2008 at 13:35 Comment(0)
C
8

can you use the getpid() function found in unistd.h ?

osx reference

Compatible answered 3/9, 2008 at 13:51 Comment(0)
C
1

GetProcessPID is what you need. This takes a ProcessSerialNumber, which you can obtain from GetCurrentProcess.

Covert answered 4/9, 2008 at 13:6 Comment(1)
That's the objective c api, the question is for c++Ancohuma
B
1

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

Bonina answered 15/9, 2008 at 0:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.