Lsof (LiSt Open Files) lists information about files that are open by the
running processes.  An open file may be a regular file, a directory, a block
special file, a character special file, an executing text reference, a
library, a stream or a network file (Internet socket, NFS file or Unix domain
socket).

lsof(8) runs sgid kmem. However, the code has NOT been audited... you
have been warned.

Main use of lsof  will be for writing cross-platforms scripts.
OpenBSD includes fstat(1), which serves the same basic purpose.