Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get PID of currently executed application

While debugging on XCode, I wanted to find out how to get the PID of the currently debugged application, from this sample;

2012-07-02 16:02:02.124 appname[14995:700]

which one of those is the pid? i need to get the pid because i wanted to check a memory leak using malloc_history which requires the pid of the application,

i tried the ff: combinations,

shell malloc_history
 app 
 appname.app
 appname[14995]
 appname[14995:700]
 14995
 14995:700
 700
0x000000 (address)

but I always get the process does not exist in the history tbe (malloc_history cannot find a process you have access to which has a name like "")

like image 240
mirageservo Avatar asked Nov 03 '22 20:11

mirageservo


1 Answers

If you're using Cocoa you can use:

[NSProcessInfo processInfo].processIdentifier;
like image 67
gngrwzrd Avatar answered Nov 15 '22 04:11

gngrwzrd