[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How /proc/self behave?

On Sun, Apr 13, 2003 at 07:02:03PM +0800, jqdkf@zju.edu.cn wrote:
> I find that when I use different id to login, the /proc/self can always
> point to the relative directory of the id, I want to know how this is
> achieved.

In general, /proc is magic. Everything there is synthesized by the
kernel. The kernel arranges that /proc/self always appears as if it were
a symlink to /proc/<pid>, where <pid> is the process ID of the process
reading the symlink.

You'll find the code for /proc/self in fs/proc/base.c in the kernel
source (at least in 2.4.20).


Colin Watson                                  [cjwatson@flatline.org.uk]

Reply to: