aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2010-02-01 22:46:56 +0200
committerLasse Collin <lasse.collin@tukaani.org>2010-02-01 22:46:56 +0200
commit455e68c030fde8a8c2f5e254c3b3ab9489bf3735 (patch)
tree0a3bbab2e5c645d647d328b383a786a276a3a74b /src
parentFix compression of symlinks with --force. (diff)
downloadxz-455e68c030fde8a8c2f5e254c3b3ab9489bf3735.tar.xz
Fix signal handling for --list.
Diffstat (limited to 'src')
-rw-r--r--src/xz/main.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/xz/main.c b/src/xz/main.c
index 05a1d66d..842f5eaf 100644
--- a/src/xz/main.c
+++ b/src/xz/main.c
@@ -176,10 +176,17 @@ main(int argc, char **argv)
}
}
- // Hook the signal handlers. We don't need these before we start
- // the actual action, so this is done after parsing the command
- // line arguments.
- signals_init();
+ // Set up the signal handlers. We don't need these before we
+ // start the actual action and not in --list mode, so this is
+ // done after parsing the command line arguments.
+ //
+ // 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.
// 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
- // 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)
list_totals();