pwdx: cannot resolve cwd for 6239 : No such file or directory

When I tried to check the current work directory of a process, it failed with the message as shown in the title.

I looked up some articles saying this is because the program I launched from within a directory that is later removed. But I don't think the directory is removed. So I am confused why this happen.

And I checked the implementation of the pwdx.c, and found:

void) snprintf(proc, sizeof (proc), [b]"/proc/%d/path/cwd[/b]",(int)p.pr_pid);

if ((ret = readlink(proc, cwd, sizeof (cwd) - 1)) <= 0)

The code is checking, e.g. /proc/6239/path/cwd. But in the /proc filesystem, I didn't see any "path" in the directory, e.g. /proc/972/cwd

How can I check if my system is using this implementation? Will this be the root cause of the problem?

Thanks in advance.

[818 byte] By [lushua] at [2007-11-27 0:13:50]
# 1
The code I referenced should be:(void) snprintf(proc, sizeof (proc), "/proc/%d/path/cwd", (int)p.pr_pid);
lushua at 2007-7-11 21:58:09 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2

proc(4) says:

...

cwd

A symbolic link to the process's current working directory.

See chdir(2). A readlink(2) of /proc/pid/cwd yields a null

string. However, it can be opened, listed, and searched as

a directory, and can be the target of chdir(2).

...

path

A directory containing symbolic links to files opened by the

process...

But I don't think it answers _your_ question; maybe its better to post it to OpenSolaris forums:, for example, this one:

http://www.opensolaris.org/jive/forum.jspa?forumID=31&start=0

MaximKartasheva at 2007-7-11 21:58:09 > top of Java-index,Development Tools,Solaris and Linux Development Tools...