* lib/fatal-signal.h (at_fatal_signal): Change return type to 'int'.
* lib/fatal-signal.c: Don't include xalloc.h.
(at_fatal_signal): Return an error indicator.
* modules/fatal-signal (Depends-on): Remove xalloc.
* NEWS: Mention the change.
* lib/term-style-control.c: Include xalloc.h.
(ensure_other_signal_handlers): Test return value of at_fatal_signal.
* lib/clean-temp.c (do_init_clean_temp): Likewise.
* lib/wait-process.c (register_slave_subprocess): Likewise.
* modules/term-style-control (Depends-on): Add xalloc-die.
* modules/clean-temp (Depends-on): Likewise.
* modules/wait-process (Depends-on): Likewise.
+2021-03-21 Bruno Haible <bruno@clisp.org>
+
+ fatal-signal: Remove dependency upon xalloc.
+ * lib/fatal-signal.h (at_fatal_signal): Change return type to 'int'.
+ * lib/fatal-signal.c: Don't include xalloc.h.
+ (at_fatal_signal): Return an error indicator.
+ * modules/fatal-signal (Depends-on): Remove xalloc.
+ * NEWS: Mention the change.
+ * lib/term-style-control.c: Include xalloc.h.
+ (ensure_other_signal_handlers): Test return value of at_fatal_signal.
+ * lib/clean-temp.c (do_init_clean_temp): Likewise.
+ * lib/wait-process.c (register_slave_subprocess): Likewise.
+ * modules/term-style-control (Depends-on): Add xalloc-die.
+ * modules/clean-temp (Depends-on): Likewise.
+ * modules/wait-process (Depends-on): Likewise.
+
2021-03-21 Paul Eggert <eggert@cs.ucla.edu>
diacrit: remove
Date Modules Changes
+2021-03-21 fatal-signal The function at_fatal_signal now returns an error
+ indicator.
+
2021-03-21 diacrit This deprecated module is removed.
2021-03-07 mbrtowc For single-locale optimizations, you now need to
/* Initialize the data used by the cleanup handler. */
init_fatal_signal_set ();
/* Register the cleanup handler. */
- at_fatal_signal (&cleanup_action);
+ if (at_fatal_signal (&cleanup_action) < 0)
+ xalloc_die ();
}
/* Ensure that do_init_clean_temp is called once only. */
#include "glthread/lock.h"
#include "thread-optim.h"
#include "sig-handler.h"
-#include "xalloc.h"
#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
/* Register a cleanup function to be executed when a catchable fatal signal
occurs. */
-void
+int
at_fatal_signal (action_t action)
{
bool mt = gl_multithreaded ();
cleanup_initialized = true;
}
+ int ret = 0;
+
if (actions_count == actions_allocated)
{
/* Extend the actions array. Note that we cannot use xrealloc(),
size_t old_actions_allocated = actions_allocated;
size_t new_actions_allocated = 2 * actions_allocated;
actions_entry_t *new_actions =
- XNMALLOC (new_actions_allocated, actions_entry_t);
- size_t k;
+ (actions_entry_t *)
+ malloc (new_actions_allocated * sizeof (actions_entry_t));
+ if (new_actions == NULL)
+ {
+ ret = -1;
+ goto done;
+ }
+ size_t k;
/* Don't use memcpy() here, because memcpy takes non-volatile arguments
and is therefore not guaranteed to complete all memory stores before
the next statement. */
actions[actions_count].action = action;
actions_count++;
+ done:
if (mt) gl_lock_unlock (at_fatal_signal_lock);
+
+ return ret;
}
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 (_GL_ASYNC_SAFE void (*function) (int sig));
+ or not.
+
+ Return 0 upon success, or -1 if there was a memory allocation problem. */
+extern int at_fatal_signal (_GL_ASYNC_SAFE void (*function) (int sig));
/* Sometimes it is necessary to block the usually fatal signals while the
#include "sig-handler.h"
#include "full-write.h"
#include "same-inode.h"
+#include "xalloc.h"
#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
if (!signal_handlers_installed)
{
/* Install the handlers for the fatal signals. */
- at_fatal_signal (fatal_signal_handler);
+ if (at_fatal_signal (fatal_signal_handler) < 0)
+ xalloc_die ();
#if defined SIGCONT
if (!cleanup_slaves_registered)
{
atexit (cleanup_slaves);
- at_fatal_signal (cleanup_slaves_action);
+ if (at_fatal_signal (cleanup_slaves_action) < 0)
+ xalloc_die ();
cleanup_slaves_registered = true;
}
mkdtemp
rmdir
xalloc
+xalloc-die
xmalloca
linkedhash-list
linked-list
Depends-on:
c99
-xalloc
stdbool
unistd
sigaction
full-write
fstat
same-inode
+xalloc-die
configure.ac:
AC_REQUIRE([AC_C_INLINE])
fatal-signal
error
xalloc
+xalloc-die
gettext-h
stdbool
stdlib