Mr. Duan
Mr. Duan

Reputation: 81

How to get current process pid?

I need to get the pid of current processs on Mac OS? I find that GetCurrentProcess function is deprecated. So is there any other methods?

Upvotes: 1

Views: 3652

Answers (2)

user149341
user149341

Reputation:

By using getpid(), just like any other UNIX system. (The documentation I've linked to is related to iOS, but the system call works identically on macOS.)

The GetCurrentProcess call was part of the Carbon API, which was made available for porting applications from Mac OS 9. It's no longer available in current versions of macOS.

Upvotes: 3

Vikram Saini
Vikram Saini

Reputation: 2771

You can install pidof with Homebrew:

`
brew install pidof
pidof <process_name>
  `

Upvotes: -1

Related Questions