Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix reverted commit 28937161936e11ceac5acccf0b547055cc67a79e.
authorAugustin Degomme <degomme@idpann.imag.fr>
Thu, 19 Sep 2013 13:13:54 +0000 (15:13 +0200)
committerAugustin Degomme <degomme@idpann.imag.fr>
Thu, 19 Sep 2013 13:13:54 +0000 (15:13 +0200)
src/simgrid/sg_config.c
src/xbt/xbt_main.c

index f66e1bf..fe33f2b 100644 (file)
@@ -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) {
index 59b050c..b11a855 100644 (file)
@@ -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();