in reply to File IO problem

Maybe you could look into using fuser. See man page for fuser.