|
From: Tim W. <tim...@gm...> - 2005-01-20 14:12:52
|
On Thu, 20 Jan 2005 14:22:03 +0100 (CET), Yves <yme...@pe...> wrote:
> 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 way 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();
> }
void pp_exit(int status)
preferably.
>
> 2/ Replace *all* calls to exit() with pp_exit(). Don't make a macro for that. It has to
> be a real replacement.
there are around 50 exit calls :)
>
> 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.
In the case of this problem: if the main process finishes, you should
call close_all_log_sources, but any subproces that exits should not do
this. perhaps pp_exit can do different things depending on the status
flag. So I have a feeling this will not be trivial.
>
> 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.
I agree.
Tim.
>
>
> > 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
>
>
> --
> - 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/ -
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
> Tool for open source databases. Create drag-&-drop reports. Save time
> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
> _______________________________________________
> Perfparse-devel mailing list
> Per...@li...
> https://lists.sourceforge.net/lists/listinfo/perfparse-devel
>
|