From 57de5d03ef3b610d68783b975bab3f3c4f979020 Mon Sep 17 00:00:00 2001 From: Thomas Munro Date: Sun, 24 Jul 2022 00:54:07 +1200 Subject: [PATCH 04/13] Remove configure probe for setsid. setsid() is in SUSv2 and all targeted Unix systems have it. This can be replaced with a test that we're not on Windows. --- configure | 2 +- configure.ac | 1 - src/backend/postmaster/postmaster.c | 4 ++-- src/backend/storage/ipc/procarray.c | 2 +- src/backend/storage/ipc/signalfuncs.c | 2 +- src/backend/utils/init/miscinit.c | 2 +- src/backend/utils/init/postinit.c | 4 ++-- src/bin/pg_ctl/pg_ctl.c | 2 +- src/include/pg_config.h.in | 3 --- src/tools/msvc/Solution.pm | 1 - 10 files changed, 9 insertions(+), 14 deletions(-) diff --git a/configure b/configure index 276fcb647c..62ff8250d4 100755 --- a/configure +++ b/configure @@ -16039,7 +16039,7 @@ fi LIBS_including_readline="$LIBS" LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'` -for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readlink readv setproctitle setproctitle_fast setsid strchrnul strsignal symlink syncfs sync_file_range uselocale wcstombs_l writev +for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readlink readv setproctitle setproctitle_fast strchrnul strsignal symlink syncfs sync_file_range uselocale wcstombs_l writev 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.ac b/configure.ac index 7ec30a7486..eb29046398 100644 --- a/configure.ac +++ b/configure.ac @@ -1809,7 +1809,6 @@ AC_CHECK_FUNCS(m4_normalize([ readv setproctitle setproctitle_fast - setsid strchrnul strsignal symlink diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 1c25457526..b67e82a969 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -4024,7 +4024,7 @@ PostmasterStateMachine(void) /* * Send a signal to a postmaster child process * - * On systems that have setsid(), each child process sets itself up as a + * On Unix systems, each child process uses setsid() to set itself up as a * process group leader. For signals that are generally interpreted in the * appropriate fashion, we signal the entire process group not just the * direct child process. This allows us to, for example, SIGQUIT a blocked @@ -4042,7 +4042,7 @@ signal_child(pid_t pid, int signal) { if (kill(pid, signal) < 0) elog(DEBUG3, "kill(%ld,%d) failed: %m", (long) pid, signal); -#ifdef HAVE_SETSID +#ifndef WIN32 switch (signal) { case SIGINT: diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index dadaa958a8..b680c14748 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -3869,7 +3869,7 @@ TerminateOtherDBBackends(Oid databaseId) * If we have setsid(), signal the backend's whole process * group */ -#ifdef HAVE_SETSID +#ifndef WIN32 (void) kill(-pid, SIGTERM); #else (void) kill(pid, SIGTERM); diff --git a/src/backend/storage/ipc/signalfuncs.c b/src/backend/storage/ipc/signalfuncs.c index 6e310b14eb..e2dfb4ff00 100644 --- a/src/backend/storage/ipc/signalfuncs.c +++ b/src/backend/storage/ipc/signalfuncs.c @@ -93,7 +93,7 @@ pg_signal_backend(int pid, int sig) */ /* If we have setsid(), signal the backend's whole process group */ -#ifdef HAVE_SETSID +#ifndef WIN32 if (kill(-pid, sig)) #else if (kill(pid, sig)) diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index eb43b2c5e5..70018ca5d0 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -145,7 +145,7 @@ InitPostmasterChild(void) * children, but for consistency we make all postmaster child processes do * this. */ -#ifdef HAVE_SETSID +#ifndef WIN32 if (setsid() < 0) elog(FATAL, "setsid() failed: %m"); #endif diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index a5c208a20a..3c77b1aa60 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -1249,7 +1249,7 @@ StatementTimeoutHandler(void) if (ClientAuthInProgress) sig = SIGTERM; -#ifdef HAVE_SETSID +#ifndef WIN32 /* try to signal whole process group */ kill(-MyProcPid, sig); #endif @@ -1262,7 +1262,7 @@ StatementTimeoutHandler(void) static void LockTimeoutHandler(void) { -#ifdef HAVE_SETSID +#ifndef WIN32 /* try to signal whole process group */ kill(-MyProcPid, SIGINT); #endif diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 3157d51918..bb46723e3b 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -478,7 +478,7 @@ start_postmaster(void) * group and make it a group leader, so that it doesn't get signaled along * with the current group that launched it. */ -#ifdef HAVE_SETSID +#ifndef WIN32 if (setsid() < 0) { write_stderr(_("%s: could not start server due to setsid() failure: %s\n"), diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 922756568e..9a3372f7de 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -477,9 +477,6 @@ /* 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 - /* Define to 1 if the system has the type `socklen_t'. */ #undef HAVE_SOCKLEN_T diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm index 893feb6eaf..e3b60a773a 100644 --- a/src/tools/msvc/Solution.pm +++ b/src/tools/msvc/Solution.pm @@ -352,7 +352,6 @@ sub GenerateFiles HAVE_SETENV => undef, HAVE_SETPROCTITLE => undef, HAVE_SETPROCTITLE_FAST => undef, - HAVE_SETSID => undef, HAVE_SOCKLEN_T => 1, HAVE_SPINLOCKS => 1, HAVE_STDBOOL_H => 1, -- 2.30.2