about summary refs log tree commit diff
path: root/stdlib
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-12-12 02:33:49 +0000
committerUlrich Drepper <drepper@redhat.com>1997-12-12 02:33:49 +0000
commit87f1cf848c2f0cd35ddfbee82dda757bf8b33b4c (patch)
treeb551d30da1f5f7e9c0e015d2e25bcd031afdffad /stdlib
parent8ad9e4d15919d796a5c77d0518fd8631bd16bf6e (diff)
downloadglibc-87f1cf848c2f0cd35ddfbee82dda757bf8b33b4c.tar.gz
glibc-87f1cf848c2f0cd35ddfbee82dda757bf8b33b4c.tar.xz
glibc-87f1cf848c2f0cd35ddfbee82dda757bf8b33b4c.zip
(exit): Handle recursive calls to exit ().
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/exit.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/stdlib/exit.c b/stdlib/exit.c
index b5b85aa26e..1ed1e2521b 100644
--- a/stdlib/exit.c
+++ b/stdlib/exit.c
@@ -33,14 +33,16 @@ DEFINE_HOOK (__libc_atexit, (void))
 void
 exit (int status)
 {
-  const struct exit_function_list *l;
-
-  for (l = __exit_funcs; l != NULL; l = l->next)
+  /* We do it this way to handle recursive calls to exit () made by
+     the functions registered with `atexit' and `on_exit'. We call
+     everyone on the list and use the status value in the last
+     exit (). */
+  for (; __exit_funcs; __exit_funcs = __exit_funcs->next)
     {
-      size_t i = l->idx;
-      while (i-- > 0)
+      while ((__exit_funcs->idx)-- > 0)
 	{
-	  const struct exit_function *const f = &l->fns[i];
+	  const struct exit_function *const f =
+	    &__exit_funcs->fns[__exit_funcs->idx];
 	  switch (f->flavor)
 	    {
 	    case ef_free: