以编程方式检查进程是否正在Mac上运行 [英] Programmatically check if a process is running on Mac

查看:315
本文介绍了以编程方式检查进程是否正在Mac上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Mac上是否有可用于枚举进程的Carbon / Cocoa / C API?我在Windows上寻找 EnumProcesses



我的目标是从代码检查一个进程是否

解决方案



a href =http://developer.apple.com/mac/library/documentation/Carbon/Reference/Process_Manager/Reference/reference.html =nofollow noreferrer>流程管理器参考



看起来像 GetNextProcess GetProcessInfo 有助于弄清楚正在运行的是什么。正如Dave所建议的,如果你正在寻找守护进程而不只是Carbon / Cocoa进程,可以使用 GetBSDProcessList


Is there any Carbon/Cocoa/C API available on Macs that I can use to enumerate processes? I'm looking for something like EnumProcesses on Windows.

My goal is to check from code whether a process is running (by name).

Thanks!

解决方案

TechZen says: The Process Manager is, as of Dec 2013, completely deprecated.

Ah, I just found the Process Manager reference

Looks like GetNextProcess and GetProcessInfo help in figuring out what's running. As suggested by Dave, GetBSDProcessList can be used if you're looking for daemons and not just Carbon/Cocoa processes.

这篇关于以编程方式检查进程是否正在Mac上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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