From: Tom Lane Date: Thu, 5 Jul 2012 18:00:40 +0000 (-0400) Subject: Remove support for using wait3() in place of waitpid(). X-Git-Tag: REL9_3_BETA1~1234 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fc548b2296df3fe039bf68e196bfd883338e0faa;p=postgresql Remove support for using wait3() in place of waitpid(). All Unix-oid platforms that we currently support should have waitpid(), since it's in V2 of the Single Unix Spec. Our git history shows that the wait3 code was added to support NextStep, which we officially dropped support for as of 9.2. So get rid of the configure test, and simplify the macro spaghetti in reaper(). Per suggestion from Fujii Masao. --- diff --git a/configure b/configure index acec60c3a7..9049ad015e 100755 --- a/configure +++ b/configure @@ -19254,8 +19254,7 @@ fi - -for ac_func in cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit memmove poll pstat readlink setproctitle setsid sigprocmask symlink towlower utime utimes waitpid wcstombs wcstombs_l +for ac_func in cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit memmove poll pstat readlink setproctitle setsid sigprocmask symlink towlower utime utimes wcstombs wcstombs_l do as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` { $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 diff --git a/configure.in b/configure.in index 05e6324e8f..a362cfdf5e 100644 --- a/configure.in +++ b/configure.in @@ -1207,7 +1207,7 @@ PGAC_VAR_INT_TIMEZONE AC_FUNC_ACCEPT_ARGTYPES PGAC_FUNC_GETTIMEOFDAY_1ARG -AC_CHECK_FUNCS([cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit memmove poll pstat readlink setproctitle setsid sigprocmask symlink towlower utime utimes waitpid wcstombs wcstombs_l]) +AC_CHECK_FUNCS([cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit memmove poll pstat readlink setproctitle setsid sigprocmask symlink towlower utime utimes wcstombs wcstombs_l]) AC_REPLACE_FUNCS(fseeko) case $host_os in diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 913734fbd0..45f6ac624e 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -377,7 +377,9 @@ static void InitPostmasterDeathWatchHandle(void); #ifdef EXEC_BACKEND #ifdef WIN32 -static pid_t win32_waitpid(int *exitstatus); +#define WNOHANG 0 /* ignored, so any integer value will do */ + +static pid_t waitpid(pid_t pid, int *exitstatus, int options); static void WINAPI pgwin32_deadchild_callback(PVOID lpParameter, BOOLEAN TimerOrWaitFired); static HANDLE win32ChildQueue; @@ -388,7 +390,7 @@ typedef struct HANDLE procHandle; DWORD procId; } win32_deadchild_waitinfo; -#endif +#endif /* WIN32 */ static pid_t backend_forkexec(Port *port); static pid_t internal_forkexec(int argc, char *argv[], Port *port); @@ -2268,33 +2270,13 @@ reaper(SIGNAL_ARGS) int pid; /* process id of dead child process */ int exitstatus; /* its exit status */ - /* These macros hide platform variations in getting child status */ -#ifdef HAVE_WAITPID - int status; /* child exit status */ - -#define LOOPTEST() ((pid = waitpid(-1, &status, WNOHANG)) > 0) -#define LOOPHEADER() (exitstatus = status) -#else /* !HAVE_WAITPID */ -#ifndef WIN32 - union wait status; /* child exit status */ - -#define LOOPTEST() ((pid = wait3(&status, WNOHANG, NULL)) > 0) -#define LOOPHEADER() (exitstatus = status.w_status) -#else /* WIN32 */ -#define LOOPTEST() ((pid = win32_waitpid(&exitstatus)) > 0) -#define LOOPHEADER() -#endif /* WIN32 */ -#endif /* HAVE_WAITPID */ - PG_SETMASK(&BlockSig); ereport(DEBUG4, (errmsg_internal("reaping dead processes"))); - while (LOOPTEST()) + while ((pid = waitpid(-1, &exitstatus, WNOHANG)) > 0) { - LOOPHEADER(); - /* * Check if this child was a startup process. */ @@ -5045,8 +5027,12 @@ ShmemBackendArrayRemove(Backend *bn) #ifdef WIN32 +/* + * Subset implementation of waitpid() for Windows. We assume pid is -1 + * (that is, check all child processes) and options is WNOHANG (don't wait). + */ static pid_t -win32_waitpid(int *exitstatus) +waitpid(pid_t pid, int *exitstatus, int options) { DWORD dwd; ULONG_PTR key; diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 5454efdcbe..6521c6d5b9 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -614,9 +614,6 @@ /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF -/* Define to 1 if you have the `waitpid' function. */ -#undef HAVE_WAITPID - /* Define to 1 if you have the header file. */ #undef HAVE_WCHAR_H diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32 index 9574a8bbc7..8c232f67a0 100644 --- a/src/include/pg_config.h.win32 +++ b/src/include/pg_config.h.win32 @@ -505,9 +505,6 @@ /* Define to 1 if you have the `vsnprintf' function. */ #define HAVE_VSNPRINTF 1 -/* Define to 1 if you have the `waitpid' function. */ -/* #undef HAVE_WAITPID */ - /* Define to 1 if you have the header file. */ #define HAVE_WCHAR_H 1