aboutsummaryrefslogtreecommitdiff
path: root/src/xz/signals.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2013-06-28 23:48:05 +0300
committerLasse Collin <lasse.collin@tukaani.org>2013-06-28 23:48:05 +0300
commit9dc319eabb34a826f4945f91c71620f14a60e9e2 (patch)
tree7f92afc9d6f9031d9dcfded0f8231fd5ee7f16d6 /src/xz/signals.c
parentxz: Use non-blocking I/O for the input file. (diff)
downloadxz-9dc319eabb34a826f4945f91c71620f14a60e9e2.tar.xz
xz: Use the self-pipe trick to avoid a race condition with signals.
It is possible that a signal to set user_abort arrives right before a blocking system call is made. In this case the call may block until another signal arrives, while the wanted behavior is to make xz clean up and exit as soon as possible. After this commit, the race condition is avoided with the input side which already uses non-blocking I/O. The output side still uses blocking I/O and thus has the race condition.
Diffstat (limited to '')
-rw-r--r--src/xz/signals.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/xz/signals.c b/src/xz/signals.c
index de213644..2a1d4eb7 100644
--- a/src/xz/signals.c
+++ b/src/xz/signals.c
@@ -41,6 +41,11 @@ signal_handler(int sig)
{
exit_signal = sig;
user_abort = true;
+
+#ifndef TUKLIB_DOSLIKE
+ io_write_to_user_abort_pipe();
+#endif
+
return;
}