1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +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;
}
}

View File

@ -45,12 +45,7 @@ static int history_lines_added;
#define NL_IN_HISTORY 0x01
#endif
#ifdef HAVE_ATEXIT
static void finishInput(void);
#else
/* designed for use with on_exit() */
static void finishInput(int, void *);
#endif
/*
@ -313,11 +308,7 @@ initializeInput(int flags)
}
#endif
#ifdef HAVE_ATEXIT
atexit(finishInput);
#else
on_exit(finishInput, NULL);
#endif
}
@ -416,11 +407,7 @@ saveHistory(char *fname, int max_lines, bool appendFlag, bool encodeFlag)
static void
#ifdef HAVE_ATEXIT
finishInput(void)
#else
finishInput(int exitstatus, void *arg)
#endif
{
#ifdef USE_READLINE
if (useHistory && psql_history)

View File

@ -90,9 +90,6 @@
/* Define to 1 if you have the `append_history' function. */
#undef HAVE_APPEND_HISTORY
/* Define to 1 if you have the `atexit' function. */
#undef HAVE_ATEXIT
/* Define to 1 if you have the `cbrt' function. */
#undef HAVE_CBRT
@ -369,9 +366,6 @@
/* Define to 1 if you have the <net/if.h> header file. */
#undef HAVE_NET_IF_H
/* Define to 1 if you have the `on_exit' function. */
#undef HAVE_ON_EXIT
/* Define to 1 if you have the <ossp/uuid.h> header file. */
#undef HAVE_OSSP_UUID_H

View File

@ -72,9 +72,6 @@
# define gettimeofday(a,b) gettimeofday(a)
#endif
/* Define to 1 if you have the `atexit' function. */
#define HAVE_ATEXIT 1
/* Define to 1 if you have the `cbrt' function. */
//#define HAVE_CBRT 1
@ -279,9 +276,6 @@
/* Define to 1 if you have the <netinet/tcp.h> header file. */
/* #undef HAVE_NETINET_TCP_H */
/* Define to 1 if you have the `on_exit' function. */
/* #undef HAVE_ON_EXIT */
/* Define to 1 if you have the <pam/pam_appl.h> header file. */
/* #undef HAVE_PAM_PAM_APPL_H */