"Steve Lambert" <st***********@ntlworld.com> wrote in message
news:Tm***************@newsfe1-gui.ntli.net...
Hi,
Is it possible for the functions registered with atexit() to have access
to parameter to exit i.e EXIT_SUCCESS or EXIT_FAILURE?
I'd like to register a set of routines to be executed on
exit(EXIT_FAILURE) and a different set of routines on exit(EXIT_SUCCESS).
Any way of doing this?
My first thought was to pass this info ('failure' or 'success')
via an argument to the registered function. BUT:
==========================================
From the C standard:
7.20.4.2 The atexit function
Synopsis
1 #include <stdlib.h>
int atexit(void (*func)(void));
Description
2 The atexit function registers the function pointed to by func,
to be called without arguments at normal program termination.
Environmental limits
3 The implementation shall support the registration of at least
32 functions.
Returns
4 The atexit function returns zero if the registration succeeds,
nonzero if it fails.
==========================================
So, as much as I dislike using globals, it seems that would
be the way to pass this info: set a global to EXIT_SUCCESS
or EXIT_FAILURE (or whatever other value you find useful),
and have a 'controlling' registered function inspect that
value, and invoke one of a set of other functions which
performs the desired actions.
-Mike