diff options
author | Vojtech Kral <vojtech@kral.hk> | 2018-05-21 19:34:45 +0300 |
---|---|---|
committer | Vojtech Kral <vojtech@kral.hk> | 2018-05-21 19:59:15 +0300 |
commit | 5697754c5ea264bcea3d77165a0b5d4337da637f (patch) | |
tree | 1ff87397c32385218aa363593db7b49491f18770 /xs | |
parent | ee5a5df2a7019bf85927ccb55c31dad81ddad240 (diff) |
avrdude: Fix exit hook not being adapted properly
Diffstat (limited to 'xs')
-rw-r--r-- | xs/src/avrdude/main.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/xs/src/avrdude/main.c b/xs/src/avrdude/main.c index 71a886040..51fdf7268 100644 --- a/xs/src/avrdude/main.c +++ b/xs/src/avrdude/main.c @@ -163,6 +163,7 @@ static LISTID extended_params = NULL; static LISTID additional_config_files = NULL; static PROGRAMMER * pgm; +static bool pgm_setup = false; /* * global options @@ -365,14 +366,18 @@ static void list_parts(FILE * f, const char *prefix, LISTID avrparts) walk_avrparts(avrparts, list_avrparts_callback, &c); } -static void exithook(void) -{ - if (pgm->teardown) - pgm->teardown(pgm); -} +// static void exithook(void) +// { +// if (pgm->teardown) +// pgm->teardown(pgm); +// } static int cleanup_main(int status) { + if (pgm_setup && pgm->teardown) { + pgm->teardown(pgm); + } + if (updates) { ldestroy_cb(updates, (void(*)(void*))free_update); updates = NULL; @@ -889,6 +894,7 @@ int avrdude_main(int argc, char * argv [], const char *sys_config) if (pgm->setup) { pgm->setup(pgm); } + pgm_setup = true; // Replaces the atexit hook // if (pgm->teardown) { // atexit(exithook); // } @@ -1500,6 +1506,5 @@ main_exit: avrdude_message(MSG_INFO, "\n%s done. Thank you.\n\n", progname); } - exithook(); return cleanup_main(exitrc); } |