New modules 'unistr/u8-mbtouc-safe', 'unistr/u16-mbtouc-safe', 'unistr/u32-mbtouc...
[gnulib.git] / lib / fatal-signal.h
index ffbc4a8..3e6f677 100644 (file)
@@ -1,5 +1,5 @@
 /* Emergency actions in case of a fatal signal.
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003-2004 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software; you can redistribute it and/or modify
@@ -14,7 +14,7 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software Foundation,
-   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 
 #ifdef __cplusplus
@@ -26,10 +26,32 @@ extern "C" {
    terminates the process, like removing a temporary file or killing a
    subprocess that may be stuck waiting for a device, pipe or network input.
    Such signals are SIGHUP, SIGINT, SIGPIPE, SIGTERM, and possibly others.
-   The limitation of this facility is that it cannot work for SIGKILL.  */
+   The limitation of this facility is that it cannot work for SIGKILL.
+
+   Signals with a SIG_IGN handler are considered to be non-fatal.  The
+   functions in this file assume that when a SIG_IGN handler is installed
+   for a signal, it was installed before any functions in this file were
+   called and it stays so for the whole lifetime of the process.  */
 
 /* Register a cleanup function to be executed when a catchable fatal signal
-   occurs.  */
+   occurs.
+
+   Restrictions for the cleanup function:
+     - The cleanup function can do all kinds of system calls.
+     - It can also access application dependent memory locations and data
+       structures provided they are in a consistent state. One way to ensure
+       this is through block_fatal_signals()/unblock_fatal_signals(), see
+       below.  Another - more tricky - way to ensure this is the careful use
+       of 'volatile'.
+   However,
+     - malloc() and similarly complex facilities are not safe to be called
+       because they are not guaranteed to be in a consistent state.
+     - Also, the cleanup function must not block the catchable fatal signals
+       and leave them blocked upon return.
+
+   The cleanup function is executed asynchronously.  It is unspecified
+   whether during its execution the catchable fatal signals are blocked
+   or not.  */
 extern void at_fatal_signal (void (*function) (void));
 
 
@@ -40,7 +62,10 @@ extern void at_fatal_signal (void (*function) (void));
    functions create the temporary file or directory _before_ returning its
    name to the application.  */
 
-/* Temporarily delay the catchable fatal signals.  */
+/* Temporarily delay the catchable fatal signals.
+   The signals will be blocked (= delayed) until the next call to
+   unblock_fatal_signals().  If the signals are already blocked, a further
+   call to block_fatal_signals() has no effect.  */
 extern void block_fatal_signals (void);
 
 /* Stop delaying the catchable fatal signals.  */