Browse - Programming Tips - Why do I get a different number each time I list /proc/self ?
Q. Why do I get a different number each time I list /proc/self ?
A. When you do:
ls -l self
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:
to see your process id. Or:
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.