From 390610706189d23b8aec69754b7b8ba28e30d8b5 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sun, 24 Jul 2022 00:54:07 +1200
Subject: [PATCH v2 04/13] Remove configure probe for setsid.

setsid() is in SUSv2 and all targeted Unix systems have it.  Retain a
HAVE_SETSID macro, defined on Unix only.  That's easier to understand
than !defined(WIN32), for the optional code it governs.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CA+hUKGJ3LHeP9w5Fgzdr4G8AnEtJ=z=p6hGDEm4qYGEUX5B6fQ@mail.gmail.com
---
 configure                  | 2 +-
 configure.ac               | 1 -
 src/include/pg_config.h.in | 3 ---
 src/include/port.h         | 1 +
 src/tools/msvc/Solution.pm | 1 -
 5 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/configure b/configure
index 0c3ee5ab3f..4a332d2296 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 dab6927cdc..ce14199902 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/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/include/port.h b/src/include/port.h
index e14e8fbf7e..f46352b1eb 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -549,6 +549,7 @@ extern bool wait_result_is_any_signal(int exit_status, bool include_command_not_
  */
 #ifndef WIN32
 #define HAVE_GETRLIMIT 1
+#define HAVE_SETSID 1
 #define HAVE_SHM_OPEN 1
 #endif
 
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.35.1

