From 636ced8e1dc8248a1353b416240b93d70ad03edb Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Sun, 7 Jul 2013 01:52:51 +0200 Subject: cmdutils: wrap exit explicitly Some C runtime implementations deadlock when calling threading functions on the atexit() handler. Use a simpler wrapper similar to av_log to call the cleanup function before exit. Bug-Id: 523 --- avprobe.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'avprobe.c') diff --git a/avprobe.c b/avprobe.c index 5ad56a182b..c7b3d39cb2 100644 --- a/avprobe.c +++ b/avprobe.c @@ -60,7 +60,7 @@ static const char unit_hertz_str[] = "Hz" ; static const char unit_byte_str[] = "byte" ; static const char unit_bit_per_second_str[] = "bit/s"; -static void exit_program(void) +static void avprobe_cleanup(int ret) { av_dict_free(&fmt_entries_to_show); } @@ -366,7 +366,7 @@ static void probe_group_enter(const char *name, int type) if (!octx.prefix || !name) { fprintf(stderr, "Out of memory\n"); - exit(1); + exit_program(1); } if (octx.level) { @@ -854,7 +854,7 @@ static void opt_input_file(void *optctx, const char *arg) fprintf(stderr, "Argument '%s' provided as input filename, but '%s' was already specified.\n", arg, input_filename); - exit(1); + exit_program(1); } if (!strcmp(arg, "-")) arg = "pipe:"; @@ -919,7 +919,7 @@ int main(int argc, char **argv) if (!buffer) exit(1); - atexit(exit_program); + register_exit(avprobe_cleanup); options = real_options; parse_loglevel(argc, argv, options); @@ -949,13 +949,13 @@ int main(int argc, char **argv) fprintf(stderr, "Use -h to get full help or, even better, run 'man %s'.\n", program_name); - exit(1); + exit_program(1); } probe_out = avio_alloc_context(buffer, AVP_BUFFSIZE, 1, NULL, NULL, probe_buf_write, NULL); if (!probe_out) - exit(1); + exit_program(1); probe_header(); ret = probe_file(input_filename); -- cgit v1.2.3