You can use the -b
option to tell lsof to avoid using kernel
functions that would block. Some cautions apply.
First, using this option usually requires that your system supply
alternate device numbers in place of the device numbers that lsof
would normally obtain with the lstat(2) and stat(2) kernel
functions. See the ALTERNATE DEVICE NUMBERS
section for more
information on alternate device numbers.
Second, you can't specify names for lsof to locate unless they're
file system names. This is because lsof needs to know the device
and inode numbers of files listed with names in the lsof options,
and the -b
option prevents lsof from obtaining them. Moreover,
since lsof only has device numbers for the file systems that have
alternates, its ability to locate files on file systems depends
completely on the availability and accuracy of the alternates.
If no alternates are available, or if they're incorrect, lsof
won't be able to locate files on the named file systems.
Third, if the names of your file system directories that lsof
obtains from your system's mount table are symbolic links, lsof
won't be able to resolve the links. This is because the -b
option causes lsof to avoid the kernel readlink(2) function it
uses to resolve symbolic links.
Finally, using the -b
option causes lsof to issue warning
messages when it needs to use the kernel functions that the -b
option directs it to avoid. You can suppress these messages by
specifying the -w
option, but if you do, you won't see the
alternate device numbers reported in the warning messages.