How to get current process pid?

余生颓废 提交于 2020-01-26 03:14:39

问题


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?


回答1:


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.




回答2:


You can install pidof with Homebrew:

`
brew install pidof
pidof <process_name>
  `


来源:https://stackoverflow.com/questions/43359309/how-to-get-current-process-pid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!