Knowing that program's PID， I want to list out the executable file of a running program.
For binary programs, I can read
/proc/$pid/exe, which is a symlink to the executable.
However for scripting programs, for example a Python program,
/proc/$pid/exe points to
/usr/bin/python, not the program itself. This happens no matter I started the program with
./program.py or with
I tried several ways to solve it:
/proc/$pid/cmdline contains the filename of the script, but it is in relative path and the working directory may have changed already.
I also tried
/proc/$pid/comm but it can be easily changed by the program.
So how to know the original script file of a running program?