From: Augustin Degomme Date: Thu, 19 Sep 2013 13:13:54 +0000 (+0200) Subject: Fix reverted commit 28937161936e11ceac5acccf0b547055cc67a79e. X-Git-Tag: v3_9_90~106 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a2124935b1ed32e3279768396afbfa10729ff64d Fix reverted commit 28937161936e11ceac5acccf0b547055cc67a79e. --- diff --git a/src/simgrid/sg_config.c b/src/simgrid/sg_config.c index f66e1bf2e7..fe33f2b56e 100644 --- a/src/simgrid/sg_config.c +++ b/src/simgrid/sg_config.c @@ -318,6 +318,13 @@ static void _sg_cfg_cb_verbose_exit(const char *name, int pos) _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); @@ -838,7 +845,7 @@ void sg_config_init(int *argc, char **argv) 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) { diff --git a/src/xbt/xbt_main.c b/src/xbt/xbt_main.c index 59b050c2a2..b11a855161 100644 --- a/src/xbt/xbt_main.c +++ b/src/xbt/xbt_main.c @@ -30,6 +30,7 @@ char *xbt_binary_name = NULL; /* Name of the system process containing us (man 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. @@ -92,11 +93,12 @@ static void xbt_preinit(void) { 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();