Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find a process holding a file open

Status
Not open for further replies.

grazinggoat

Programmer
Mar 12, 2008
41
0
0
US
anyone know of a possible perl builtin / function that will show a process holding a fileopen. I looked thru stat and lstat but still unable to find something similar to lsof. Any suggestions? Thanks
 
Hi

grazinggoat said:
I looked thru stat and lstat but still unable to find something similar to lsof.
On which operating system ? Are you just trying to implement kind of [tt]lsof[/tt] in Perl, or you have some special requirement ? Neither [tt]fuser[/tt] solves your problem ?

If you want to code it yourself, iterate over the files matching [tt]^/proc/\d+/fd/\d+$[/tt] and use [tt]readlink()[/tt] on each to find out whether they point to the file in question.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top