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


沒有留言:

張貼留言

[NodeJS 文章收集] NodeJS accessing file with relative path

Source From  Here Question It seemed like a straight forward problem. But I am not able to crack this. Within  helper1.js  I would like to a...