-
-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
#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;
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);
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.
*/
#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;