Is there a way to check if a file with given name is opened by some process (other than our process)?
I need this on FreeBSD. It would be nice to also support Linux. I write in Perl.
Techniques requiring root access are not suitable.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
You should use the
fstat command, you can run it as
fstatutility identifies open files. A file is considered open by a process if it was explicitly opened, is the working directory, root directory, jail root directory, active executable text, or kernel trace file for that process. If no options are specified, fstat reports on all open files in the system.