I am trying to determine if it is possible to distinguish two separate handles in one file and one descriptor with two file descriptors pointing to it using metadata from procfs.
Case 1: Two File Descriptors
exec 3>test.lck
exec 4>test.lck
flock -x 3
flock -s 4
echo "This code is never reached"
Case 2: one pen, two FD
exec 3>test.lck
exec 4>&3
flock -x 3
flock -s 4
echo "This code gets run"
If I check the state of the system from the user environment after completing the “setup” phase and before “using”, and I want to distinguish between the two cases, are the necessary metadata available? If not, what is the best way to expose him? (Is adding kernelspace pointers in a /proc/*/fdinfosensible action that apparently can take as a patch?)