| 12 | pthread_mutex_t log_mtx = PTHREAD_MUTEX_INITIALIZER; |
| 13 | |
| 14 | void print_stack_trace(void) { |
| 15 | void *array[10]; |
| 16 | size_t size; |
| 17 | |
| 18 | // get void*'s for all entries on the stack |
| 19 | size = backtrace(array, 10); |
| 20 | |
| 21 | // print out all the frames to stderr |
| 22 | fprintf(stderr, "stack trace: \n"); |
| 23 | backtrace_symbols_fd(array, size, STDERR_FILENO); |
| 24 | } |
| 25 | |
| 26 | void print_progress(double perc) { |
| 27 | static double last_perc = 0; |