diff options
author | Thomas Munro <tmunro@postgresql.org> | 2018-07-24 13:09:22 +1200 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2018-07-24 13:09:22 +1200 |
commit | 1bc180cd2acc55e31b61c4cc9ab4b07670a2566e (patch) | |
tree | 86b2f1d8a3d572755f5c811be209ee469a74db5b | |
parent | 3214463228f45df033c14ed3925a318a99d72ce2 (diff) | |
download | postgresql-1bc180cd2acc55e31b61c4cc9ab4b07670a2566e.tar.gz postgresql-1bc180cd2acc55e31b61c4cc9ab4b07670a2566e.zip |
Use setproctitle_fast() to update the ps status, if available.
FreeBSD has introduced a faster variant of setproctitle(). Use it,
where available.
Author: Thomas Munro
Discussion: https://postgr.es/m/CAEepm=1wKMTi81uodJ=1KbJAz5WedOg=cr8ewEXrUFeaxWEgww@mail.gmail.com
-rwxr-xr-x | configure | 2 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | src/backend/utils/misc/ps_status.c | 11 | ||||
-rw-r--r-- | src/include/pg_config.h.in | 3 |
4 files changed, 14 insertions, 4 deletions
diff --git a/configure b/configure index 034ace014a4..26652133d53 100755 --- a/configure +++ b/configure @@ -14916,7 +14916,7 @@ fi LIBS_including_readline="$LIBS" LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'` -for ac_func in cbrt clock_gettime dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll posix_fallocate pstat pthread_is_threaded_np readlink setproctitle setsid shm_open symlink sync_file_range utime utimes wcstombs_l +for ac_func in cbrt clock_gettime dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll posix_fallocate pstat pthread_is_threaded_np readlink setproctitle setproctitle_fast setsid shm_open symlink sync_file_range utime utimes wcstombs_l do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --git a/configure.in b/configure.in index 5712419a274..397f6bc7651 100644 --- a/configure.in +++ b/configure.in @@ -1540,7 +1540,7 @@ PGAC_FUNC_WCSTOMBS_L LIBS_including_readline="$LIBS" LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'` -AC_CHECK_FUNCS([cbrt clock_gettime dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll posix_fallocate pstat pthread_is_threaded_np readlink setproctitle setsid shm_open symlink sync_file_range utime utimes wcstombs_l]) +AC_CHECK_FUNCS([cbrt clock_gettime dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll posix_fallocate pstat pthread_is_threaded_np readlink setproctitle setproctitle_fast setsid shm_open symlink sync_file_range utime utimes wcstombs_l]) AC_REPLACE_FUNCS(fseeko) case $host_os in diff --git a/src/backend/utils/misc/ps_status.c b/src/backend/utils/misc/ps_status.c index 83a93d24056..55521c19afd 100644 --- a/src/backend/utils/misc/ps_status.c +++ b/src/backend/utils/misc/ps_status.c @@ -38,6 +38,9 @@ bool update_process_title = true; /* * Alternative ways of updating ps display: * + * PS_USE_SETPROCTITLE_FAST + * use the function setproctitle_fast(const char *, ...) + * (newer FreeBSD systems) * PS_USE_SETPROCTITLE * use the function setproctitle(const char *, ...) * (newer BSD systems) @@ -59,7 +62,9 @@ bool update_process_title = true; * don't update ps display * (This is the default, as it is safest.) */ -#if defined(HAVE_SETPROCTITLE) +#if defined(HAVE_SETPROCTITLE_FAST) +#define PS_USE_SETPROCTITLE_FAST +#elif defined(HAVE_SETPROCTITLE) #define PS_USE_SETPROCTITLE #elif defined(HAVE_PSTAT) && defined(PSTAT_SETCMD) #define PS_USE_PSTAT @@ -286,7 +291,7 @@ init_ps_display(const char *username, const char *dbname, * Make fixed prefix of ps display. */ -#ifdef PS_USE_SETPROCTITLE +#if defined(PS_USE_SETPROCTITLE) || defined(PS_USE_SETPROCTITLE_FAST) /* * apparently setproctitle() already adds a `progname:' prefix to the ps @@ -349,6 +354,8 @@ set_ps_display(const char *activity, bool force) #ifdef PS_USE_SETPROCTITLE setproctitle("%s", ps_buffer); +#elif defined(PS_USE_SETPROCTITLE_FAST) + setproctitle_fast("%s", ps_buffer); #endif #ifdef PS_USE_PSTAT diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 3eec284dc13..b7e469670f4 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -489,6 +489,9 @@ /* Define to 1 if you have the `setproctitle' function. */ #undef HAVE_SETPROCTITLE +/* Define to 1 if you have the `setproctitle_fast' function. */ +#undef HAVE_SETPROCTITLE_FAST + /* Define to 1 if you have the `setsid' function. */ #undef HAVE_SETSID |