On Tuesday 08 August 2006 04:41, Per Jessen wrote:
I've got a daemon that uses a library that is occasionally updated - not very frequently, perhaps once per month. What I'm thinking about is having the daemon monitor this particular library for changes using inotify. I could perhaps do an automatic restart or something like that - or maybe there is a way of reloading/refreshing a library whilst running?
Another question is - is there a way of listing libraries in use from within my daemon? I could just hardcode the name, but ...
I assume you're discussing a shared library linked by the system at run time, not an object library linked at compile time. My understanding is that if the update is overwriting the library in use you would see the process core dump, because the file is memory mapped to the process. I'm also assuming you're not seeing the process core dump, because the update renames or unlinks the share library file in use before installing the new library. Assuming all the assumptions are correct ;-) ... 1) simple(er) Monitor the library with a shell script. If the file changes, the kill and restart the process. OR 2) (Another assumption -- You control the process source code and can modify and build it.) Instead of letting the system dynamic link the library change the process to link the library itself [ using dlopen() ] and monitor changes to the file [ using stat() ]. When the file changes then the process would dlclose() the library and then reopen it and then the process would need to reattach itself to the library's symbols with dlsym(). I've been brainstorming a C library at work (for Solaris) during my "copious spare time" to do option 2 more or less automatically for a process, so that we can do updates in production without bringing down an application. But, spare time what it is, I only got around to drawing squiggles on Post-It notes. Thanks, Ken Jennings