xl frequently just calls exit(3), especially on error. Try to clean
up some of our global state to make tools like valgrind more useful.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
libxl_childproc_setmode(ctx, &childproc_hooks, 0);
}
+static void xl_ctx_free(void)
+{
+ if (ctx) {
+ libxl_ctx_free(ctx);
+ ctx = NULL;
+ }
+ if (logger) {
+ xtl_logger_destroy((xentoollog_logger*)logger);
+ logger = NULL;
+ }
+ if (lockfile) {
+ free(lockfile);
+ lockfile = NULL;
+ }
+}
+
int main(int argc, char **argv)
{
int opt = 0;
logger = xtl_createlogger_stdiostream(stderr, minmsglevel, 0);
if (!logger) exit(1);
+ atexit(xl_ctx_free);
+
xl_ctx_alloc();
ret = libxl_read_file_contents(ctx, XL_GLOBAL_CONFIG,
}
xit:
- libxl_ctx_free(ctx);
- xtl_logger_destroy((xentoollog_logger*)logger);
return ret;
}