4 ms·
I believe the function of this feature was to get the executable before it could be deleted off the disk, which it presumably could in the time between the bina
by saagarjha 7y ago
I believe the function of this feature was to get the executable before it could be deleted off the disk, which it presumably could in the time between the binary was executed and the call to readlink was made.
- deleted 7y ago[deleted]
- firethief 7y agoI'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.