From: Yves <yme...@pe...> - 2005-01-20 13:22:08
|
The registered atexit() functions are inherited by subprocesses. I found = that problem when I coded periodic cleanup procedures. Now you find that problem too. Maybe it's time to think of a smarter way to exit ? Reimplement exit() with a way to remove atexit() handlers ? I found no wa= y to remove a handler that was registered with atexit. If you know one, maybe all what = I say below is N/A ? :) Here is what I suggest (I hope Remi and Bruno have had time to subscribe = to this list) 1/ Implement a basic pp_exit() function : void pp_exit(void) { exit(); } 2/ Replace *all* calls to exit() with pp_exit(). Don't make a macro for t= hat. It has to be a real replacement. 3/ Make a macro for exit() for security : void unexpected_exit(void) { pp_log(..., "This is a bug : this function should not have been called"= ); exit() } #define exit unexpected_exit Any programmer who would then use exit() (because they don't necessarily = know about pp_exit) would generate this message. 4/ work on pp_exit() in order to make it do what we want. Also remove the= calls to atexit() and do something else. Tim, I don't have an idea for a shorter way for you to test. And I think = this change is necessary, at least for perfparsed. > FYI: > I tried to register my own atexit function in perfparsed, that calls > storage_atexit & close_all_log_sources. > Unfortunately, this function gets called serveral times (each time a > forked subprocess exits), and hence it does not do what you'd want. > I'm not experienced enough in this matter to figure out how to get the > exit handler to run only when the main process exits. If you have an > idea how to do this, let me know, and I'll try it to see if it fixes > this problem. > > Tim --=20 - Homepage - http://ymettier.free.fr - http://www.logicacmg.com - - GPG key - http://ymettier.free.fr/gpg.txt - - Maitretarot - http://www.nongnu.org/maitretarot/ - - Perfparse - http://perfparse.sf.net/ - |