如何获得Unix/Linux中进程的路径 [英] How do I get the path of a process in Unix / Linux

查看:68
本文介绍了如何获得Unix/Linux中进程的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows环境中,有一个API可以获取正在运行的进程的路径. Unix/Linux中有类似的东西吗?

In Windows environment there is an API to obtain the path which is running a process. Is there something similar in Unix / Linux?

或者在这些环境中还有其他方法可以做到吗?

Or is there some other way to do that in these environments?

推荐答案

在Linux上,符号链接/proc/<pid>/exe具有可执行文件的路径.使用命令readlink -f /proc/<pid>/exe来获取值.

On Linux, the symlink /proc/<pid>/exe has the path of the executable. Use the command readlink -f /proc/<pid>/exe to get the value.

在AIX上,此文件不存在.您可以比较cksum <actual path to binary>cksum /proc/<pid>/object/a.out.

On AIX, this file does not exist. You could compare cksum <actual path to binary> and cksum /proc/<pid>/object/a.out.

这篇关于如何获得Unix/Linux中进程的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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