Linux API 列出正在运行的进程?

编程入门 行业动态 更新时间:2024-10-28 10:35:27
本文介绍了Linux API 列出正在运行的进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我需要一个 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/

http://procps.cvs.sourceforge/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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-18 17:14:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/943855.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:正在运行   进程   Linux   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!