Date: 2012mar10
OS: Linux
Q. Why do I get a different number each time I list /proc/self ?
A. When you do:
cd /proc
ls -l self
Example output:
lrwxrwxrwx 1 root root 64 Mar 9 23:32 self -> 17520/
A new process is started to run ls. Its the process id for ls
you are seeing.
From the shell you can do:
echo $$
to see your process id. Or:
PID=$$
echo My PID is $PID
in a shell script.
From a C program do:
pit_t pid = getpid();
Still /proc/self is cool and useful. From a program you can read
things from its folder.