On Aug 22, 2007, at 6:38 PM, Michal Taurich wrote:
I did it in my script with
checking "lsof" if the file is used or not. Isn't there any other
in launchd or Lingon ?
Unfortunately, there are no facilities in the OS for knowing whether
a file is open or not.
popen of lsof will work, assuming you use the output format specifiers
to prevent it from changing output format on you, or simply look at
the found/not fond return value.
The point of forcing you to write wrappers around standard tools
instead of doing what the tool does is to ensure you that when the
system is updated, you are guaranteed that the tools are updated at
the same time that the kernel and other system components are updated,
so your code will continue working, even if we change the system
interface used by the tool.
For example, here's a function that takes a pid and returns the
resident set size of a process (limited to 32 bits because I
implemented it quickly) or < 0 on error:
/* NB: returns signed int; not suitable for processes with > 2TB RSS */
This function will remain operational so long as ps remains
operational, and the standards do not change, despite software updates.
Of course, you could also write a kauth kext and keep track of this
information yourself, too.
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden