tags:

views:

72

answers:

2

Is there any way of determining the current working directory of an already running program in Linux?

What I'm trying to achieve is I want to be able to work in a terminal and then have a keyboard shortcut set up which will run a tool which I am writing which displays a little popup window containing some information and a few buttons to perform actions. This tool requires a working directory so that it knows what data to work on and I want to be able to set it up so that it will work on the directory in which I am working in the terminal.

+7  A: 

/proc/PID/cwd is a symlink to PIDs working directory:

jesperes@virtual-ubuntu $ ls /proc/self/cwd
lrwxrwxrwx 1 jesperes 0 2009-05-29 18:56 /proc/self/cwd -> /home/jesperes/hacks
jesperes@virtual-ubuntu $
JesperE
Thanks! This will do for my needs! :-P
Dan
+2  A: 

Take a look at getcwd()

There is also a symlink to the cwd in /proc/[pid]/cwd

Boris Guéry