Radim Blazek wrote: > There is a problem in G_fatal_error(): > > static int busy > if (busy) > exit(EXIT_FAILURE); > busy = 1; > > second G_fatal_error() call always exits. > > The busy check is there for the case when print error routine itself > ends up with call to G_fatal_error()?
It's there to prevent infinite recursion, whether from the printing code, a fatal error handler, or whatever. > May be the busy variable made global and added a function to clear it? That might be going a bit too far. OTOH, it can't be cleared prior to calling the handler because it's intended to protect against the case of a handler generating a fatal error. One possibility would be to add explicit support for longjmp()ing out, e.g. adding G_error_longjmp(jmp_buf env, int val) which would clear the busy flag then perform the longjmp. That would avoid exposing the internals more than is necessary. Also, currently the global error handler (G_set_error_routine) is called before the non-exclusive handlers (G_add_error_handler), so those will never be called if the global handler lonjmp()s out. The global error handler isn't limited to fatal errors, but is also used for messages and warnings. Perhaps we need a dedicated fatal error handler for this purpose? It would be called immediately prior to the final exit() call. It would not be allowed to call GRASS functions or to return. The busy flag could be cleared before calling it. -- Glynn Clements <gl...@gclements.plus.com> _______________________________________________ grass-dev mailing list grass-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-dev