程式扎記: [Linux 常見問題] How do I get the path of a process in Unix / Linux

標籤

2016年2月29日 星期一

[Linux 常見問題] How do I get the path of a process in Unix / Linux

Source From Here
Question
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?

How-To
If you want the path of the current executable, look at /proc/$PID/exe, which is a symlink to it. For example:
# ./a.out & // Sleep 10 second
[1] 22383
# ls -hl /proc/22383/exe
lrwxrwxrwx. 1 root root 0 3月 1 11:07 /proc/22383/exe -> /root/PhishTankWH/a.out


沒有留言:

張貼留言

網誌存檔

關於我自己

我的相片
Where there is a will, there is a way!