确定进程的架构
是否有一种编程方法可以找出另一个进程在 Mac OS X 10.5 及更高版本上运行的架构?
检查进程的映像文件并不是解决方案,因为映像可能包含多个体系结构,并且在 arch(1) 和“在 Rosetta 中打开”和“以 32 位模式打开”复选框之间,无法区分仅是架构实际运行的映像。
Is there a programmatic way to find out what architecture another process is running as on Mac OS X 10.5 and later?
Examining the process's image file is not a solution, as the image is likely to contain multiple architectures, and between arch(1) and the “Open in Rosetta” and “Open in 32-bit mode” checkboxes, there's no way to tell from the image alone which architecture is actually running.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以在可用的操作系统上使用 NSRunningApplication ,而在不可用时回退到 sysctl 吗?我不认为 sysctl 的东西像大多数东西一样是可支持的 API,但如果你只在旧操作系统上使用它,你应该没问题。
请尝试以下操作来获取进程的 CPU 类型:
并测试
CPU_ARCH_ABI64
以检查是否为 64 位。Can you use NSRunningApplication on OSes where it is available, and fall back to sysctl stuff when it isn't? I don't think sysctl stuff is supportable API the way most stuff is, but if you're only using it on old OSes you should be okay.
Try this to get the CPU type of the process:
And test
CPU_ARCH_ABI64
to check for 64-bit.您没有说出您的要求是什么,而是 NSRunningApplication 类为此提供了一个非常简单的接口。该文档目前有点偏离,但它就在那里。
You don't say what your requirements are, but the NSRunningApplication class introduced in 10.6 offers a really easy interface for this. The docs are currently a little off, but it is there.