如何获取当前进程的pid?
问题描述:
我需要获取Mac OS上当前进程的pid吗? 我发现不赞成使用GetCurrentProcess函数. 还有其他方法吗?
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?
答
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.)
GetCurrentProcess调用是Carbon API的一部分,可用于从Mac OS 9移植应用程序.在当前版本的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.