Linux的API来列出正在运行的进程? [英] Linux API to list running processes?

查看:172
本文介绍了Linux的API来列出正在运行的进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个C / C ++的API,允许我可以列出一个Linux系统上运行的进程,并列出文件中的每个进程打开。

I need a C/C++ API that allows me to list the running processes on a Linux system, and list the files each process has open.

我的的要结束了直接读取的/ proc /文件系统。

I do not want to end up reading the /proc/ file system directly.

任何人都可以想办法做到这一点?

Can anyone think of a way to do this?

推荐答案

http://procps.sourceforge.net/

http://procps.cvs.sourceforge.net/viewvc/procps/procps/proc/readproc.c?view=markup

是ps和其它加工工具的来源。他们确实使用PROC(表明它可能是常规的和最好的方式)。其来源是相当的可读性。文件

Is the source of ps and other process tools. They do indeed use proc (indicating it is probably the conventional and best way). Their source is quite readable. The file

/procps-3.2.8/proc/readproc.c

可能有用。另外,作为一个有用的建议按ephemient 被链接到由 libproc 提供的API,这应该是在你的回购可用(或已安装的我会说)上发布,但你需要为标题和什么,而不是在-dev的变化。

May be useful. Also a useful suggestion as posted by ephemient is linking to the API provided by libproc, which should be available in your repo (or already installed I would say) but you will need the "-dev" variation for the headers and what-not.

好运

这篇关于Linux的API来列出正在运行的进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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