_sg_do_verbose_exit = xbt_cfg_get_boolean(_sg_cfg_set, name);
}
+extern int _sg_do_clean_atexit;
+
+static void _sg_cfg_cb_clean_atexit(const char *name, int pos)
+{
+ _sg_do_clean_atexit = xbt_cfg_get_boolean(_sg_cfg_set, name);
+}
+
static void _sg_cfg_cb_context_factory(const char *name, int pos) {
smx_context_factory_name = xbt_cfg_get_string(_sg_cfg_set, name);
xbt_cfg_register(&_sg_cfg_set, "clean_atexit",
"\"yes\" or \"no\". \"yes\" enables all the cleanups of SimGrid (XBT,SIMIX,MSG) to be registered with atexit. \"no\" may be useful if your code segfaults when calling the exit function.",
xbt_cfgelm_boolean, &default_value, 1, 1,
- NULL, NULL);
+ _sg_cfg_cb_clean_atexit, NULL);
xbt_cfg_setdefault_boolean(_sg_cfg_set, "clean_atexit", default_value);
if (!surf_path) {
xbt_dynar_t xbt_cmdline = NULL; /* all we got in argv */
int xbt_initialized = 0;
+int _sg_do_clean_atexit = 1;
/* Declare xbt_preinit and xbt_postexit as constructor/destructor of the library.
* This is crude and rather compiler-specific, unfortunately.
srand(seed);
srand48(seed);
+ atexit(xbt_postexit);
}
static void xbt_postexit(void)
{
- if(!sg_cfg_get_boolean("clean_atexit")) return;
+ if(!_sg_do_clean_atexit) return;
xbt_backtrace_postexit();
xbt_fifo_postexit();
xbt_dict_postexit();