Reputation: 2129
I need to get PID of foreground app programatically(in C or Obj C) in OS X.
How to solve the following problem?
Upvotes: 0
Views: 878
Reputation: 572
... In a more general way, using the Terminal, entering "top" will display all current active processes, their PID, Uptime, CPU usage [....]...
Upvotes: 0
Reputation: 2993
This should do it:
pid_t pid=NSWorkspace.sharedWorkspace.frontmostApplication.processIdentifier;
Upvotes: 7