Fix signal handling for --list.

This commit is contained in:
Lasse Collin 2010-02-01 22:46:56 +02:00
parent 82220a1490
commit 455e68c030
1 changed files with 14 additions and 5 deletions

View File

@ -176,10 +176,17 @@ main(int argc, char **argv)
} }
} }
// Hook the signal handlers. We don't need these before we start // Set up the signal handlers. We don't need these before we
// the actual action, so this is done after parsing the command // start the actual action and not in --list mode, so this is
// line arguments. // done after parsing the command line arguments.
signals_init(); //
// It's good to keep signal handlers in normal compression and
// decompression modes even when only writing to stdout, because
// we might need to restore O_APPEND flag on stdout before exiting.
// In --test mode, signal handlers aren't really needed, but let's
// keep them there for consistency with normal decompression.
if (opt_mode != MODE_LIST)
signals_init();
// coder_run() handles compression, decopmression, and testing. // coder_run() handles compression, decopmression, and testing.
// list_file() is for --list. // list_file() is for --list.
@ -244,7 +251,9 @@ main(int argc, char **argv)
} }
// All files have now been handled. If in --list mode, display // All files have now been handled. If in --list mode, display
// the totals before exiting. // the totals before exiting. We don't have signal handlers
// enabled in --list mode, so we don't need to check user_abort.
assert(!user_abort);
if (opt_mode == MODE_LIST) if (opt_mode == MODE_LIST)
list_totals(); list_totals();