3 ms·
I've looked into it some more; I had assumed /proc/*/exe acted like a symlink whose value never changed, but actually it's more complicated[1]. As a result (onl
by firethief 7y ago
I've looked into it some more; I had assumed /proc/*/exe acted like a symlink whose value never changed, but actually it's more complicated[1]. As a result (only considering Linux here), there actually is a race condition in what they're doing: /proc/self/exe will have " (deleted)" appended if the executable is deleted. In an apparent attempt to make the problem more subtle, they're doing the readlink on every program startup so that if the value is needed, it will be correct--unless the file was deleted between when it was exec'd and when it got to the readlink call.
1: https://unix.stackexchange.com/questions/197854/how-does-the-proc-pid-exe-symlink-differ-from-ordinary-symlinks https://unix.stackexchange.com/questions/197854/how-does-the...
- saagarjha 7y agoYup, that's exactly it.