Preferably portably, but at least under Linux, is there a way to determine if two file descriptors are duplicates referring to the same open file description?
On Linux 5.12, you can use the kcmp syscall with KCMP_FILE
to determine if two file descriptors refer to the same open file description.