How to detect if a file was closed?
问题 is it possible to detect if a file (e.g. a pdf file opened in preview) was closed? The FSEvents API does not fire such an event. Maybe I could observe the associated process or something like that?! 回答1: Yes there is the way that you can find out whether file has been closed or not. So below i tried with unix lsof -t yourFilePath command to determine the same and hence have implemented the same in cocoa. Please follow below here lsof -t yourFilePath will give you the process id of only open