diff options
author | Jakub Jelinek <jakub@redhat.com> | 2009-03-09 14:35:26 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2009-03-09 14:35:26 +0000 |
commit | 5c1d419918b3637170da9a5592049048aaf0ee49 (patch) | |
tree | 8ad672f8707275fdbeaf5b8a45eeb2bc8144623a /stdlib/exit.c | |
parent | 48da74123eca38beeaec03d3d46ba09f069ef7dc (diff) |
Updated to fedora-glibc-20090309T1421cvs/fedora-glibc-2_9_90-9
Diffstat (limited to 'stdlib/exit.c')
-rw-r--r-- | stdlib/exit.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/stdlib/exit.c b/stdlib/exit.c index bc4cb0fd08..539ae4bd7e 100644 --- a/stdlib/exit.c +++ b/stdlib/exit.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1991,95,96,97,99,2001,2002,2005 Free Software Foundation, Inc. +/* Copyright (C) 1991,95,96,97,99,2001,2002,2005,2009 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -30,20 +31,22 @@ DEFINE_HOOK (__libc_atexit, (void)) in the reverse of the order in which they were registered perform stdio cleanup, and terminate program execution with STATUS. */ void -exit (int status) +attribute_hidden +__run_exit_handlers (int status, struct exit_function_list **listp, + bool run_list_atexit) { /* 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 (). */ - while (__exit_funcs != NULL) + while (*listp != NULL) { - struct exit_function_list *old; + struct exit_function_list *cur = *listp; - while (__exit_funcs->idx > 0) + while (cur->idx > 0) { const struct exit_function *const f = - &__exit_funcs->fns[--__exit_funcs->idx]; + &cur->fns[--cur->idx]; switch (f->flavor) { void (*atfct) (void); @@ -77,16 +80,23 @@ exit (int status) } } - old = __exit_funcs; - __exit_funcs = __exit_funcs->next; - if (__exit_funcs != NULL) + *listp = cur->next; + if (*listp != NULL) /* Don't free the last element in the chain, this is the statically allocate element. */ - free (old); + free (cur); } - RUN_HOOK (__libc_atexit, ()); + if (run_list_atexit) + RUN_HOOK (__libc_atexit, ()); _exit (status); } + + +void +exit (int status) +{ + __run_exit_handlers (status, __exit_funcs, true); +} libc_hidden_def (exit) |