获取进程的当前工作目录与OS X编程一个pid [英] Get the current working directory of process with a pid programmatically on OS X
本文介绍了获取进程的当前工作目录与OS X编程一个pid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法使用它的编程PID OS X上?
Is there a way to get the current working directory of a process using it's PID programmatically on OS X?
可可,碳或AppleScript的都是可以接受的。
Cocoa, Carbon, or AppleScript are all acceptable.
这是不能接受派PWD到目前的终端窗口/标签(不想影响工作区)。
It is not acceptable to send "pwd" to the current terminal window/tab (Do not want to affect the workspace).
Linux命令pwdx也是也是不能接受(以防万一你阅读过可可的一部分)
The linux command "pwdx" also is also unacceptable (just in case you read over the "Cocoa" part)
推荐答案
在10.5及更高版本:
On 10.5 and later:
lsof的-a -p $ PID -d CWD -Fn
(preFIX与须藤
如果进程属于root。)
(Prefix with sudo
if the process is owned by root.)
这篇关于获取进程的当前工作目录与OS X编程一个pid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文