From: Ulrich Drepper Date: Fri, 12 Dec 1997 02:33:49 +0000 (+0000) Subject: (exit): Handle recursive calls to exit (). X-Git-Tag: cvs/glibc-2_0_6pre4~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87f1cf848c2f0cd35ddfbee82dda757bf8b33b4c;p=thirdparty%2Fglibc.git (exit): Handle recursive calls to exit (). --- diff --git a/stdlib/exit.c b/stdlib/exit.c index b5b85aa26ed..1ed1e2521bd 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: