aboutsummaryrefslogtreecommitdiff
path: root/src/xz/signals.h
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2009-02-05 09:12:57 +0200
committerLasse Collin <lasse.collin@tukaani.org>2009-02-05 09:12:57 +0200
commit75905a9afc0ee89954ede7d08af70d1148bf0fd9 (patch)
treefc562f9890c63c4fa7087537941165393155af14 /src/xz/signals.h
parentAnother utime() fix. (diff)
downloadxz-75905a9afc0ee89954ede7d08af70d1148bf0fd9.tar.xz
Various code cleanups the the xz command line tool.
It now builds with MinGW.
Diffstat (limited to 'src/xz/signals.h')
-rw-r--r--src/xz/signals.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/xz/signals.h b/src/xz/signals.h
new file mode 100644
index 00000000..d963a416
--- /dev/null
+++ b/src/xz/signals.h
@@ -0,0 +1,51 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+/// \file signals.h
+/// \brief Handling signals to abort operation
+//
+// Copyright (C) 2007-2009 Lasse Collin
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+/// If this is true, we will clean up the possibly incomplete output file,
+/// return to main() as soon as practical. That is, the code needs to poll
+/// this variable in various places.
+extern volatile sig_atomic_t user_abort;
+
+
+/// Initialize the signal handler, which will set user_abort to true when
+/// user e.g. presses C-c.
+extern void signals_init(void);
+
+
+#ifndef _WIN32
+
+/// Block the signals which don't have SA_RESTART and which would just set
+/// user_abort to true. This is handy when we don't want to handle EINTR
+/// and don't want SA_RESTART either.
+extern void signals_block(void);
+
+/// Unblock the signals blocked by signals_block().
+extern void signals_unblock(void);
+
+/// If user has sent us a signal earlier to terminate the process,
+/// re-raise that signal to actually terminate the process.
+extern void signals_exit(void);
+
+#else
+
+#define signals_block() do { } while (0)
+#define signals_unblock() do { } while (0)
+#define signals_exit() do { } while (0)
+
+#endif