如何获取当前进程的pid? [英] How to get current process pid?

查看:768
本文介绍了如何获取当前进程的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.

这篇关于如何获取当前进程的pid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆