1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-17 06:41:09 +03:00

Remove support for on_exit()

All supported platforms support the C89 standard function atexit()
(SunOS 4 probably being the last one not to), and supporting both
makes the code clumsy.
This commit is contained in:
Peter Eisentraut
2011-12-27 20:57:59 +02:00
parent c317a3ac16
commit d383c23f6f
7 changed files with 2 additions and 268 deletions

View File

@ -39,7 +39,7 @@
bool proc_exit_inprogress = false;
/*
* This flag tracks whether we've called atexit(2) in the current process
* This flag tracks whether we've called atexit() in the current process
* (or in the parent postmaster).
*/
static bool atexit_callback_setup = false;
@ -51,7 +51,7 @@ static void proc_exit_prepare(int code);
/* ----------------------------------------------------------------
* exit() handling stuff
*
* These functions are in generally the same spirit as atexit(2),
* These functions are in generally the same spirit as atexit(),
* but provide some additional features we need --- in particular,
* we want to register callbacks to invoke when we are disconnecting
* from a broken shared-memory context but not exiting the postmaster.
@ -234,8 +234,6 @@ shmem_exit(int code)
* postmaster treat it as a crash --- see pmsignal.c.
* ----------------------------------------------------------------
*/
#ifdef HAVE_ATEXIT
static void
atexit_callback(void)
{
@ -243,15 +241,6 @@ atexit_callback(void)
/* ... too bad we don't know the real exit code ... */
proc_exit_prepare(-1);
}
#else /* assume we have on_exit instead */
static void
atexit_callback(int exitstatus, void *arg)
{
/* Clean up everything that must be cleaned up */
proc_exit_prepare(exitstatus);
}
#endif /* HAVE_ATEXIT */
/* ----------------------------------------------------------------
* on_proc_exit
@ -275,11 +264,7 @@ on_proc_exit(pg_on_exit_callback function, Datum arg)
if (!atexit_callback_setup)
{
#ifdef HAVE_ATEXIT
atexit(atexit_callback);
#else
on_exit(atexit_callback, NULL);
#endif
atexit_callback_setup = true;
}
}
@ -306,11 +291,7 @@ on_shmem_exit(pg_on_exit_callback function, Datum arg)
if (!atexit_callback_setup)
{
#ifdef HAVE_ATEXIT
atexit(atexit_callback);
#else
on_exit(atexit_callback, NULL);
#endif
atexit_callback_setup = true;
}
}