*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.400 2004/05/29 22:48:19 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.401 2004/05/30 03:50:11 tgl Exp $
*
* NOTES
*
static pid_t *win32_childPIDArray;
static HANDLE *win32_childHNDArray;
static unsigned long win32_numChildren = 0;
+
+HANDLE PostmasterHandle;
#endif
static pid_t backend_forkexec(Port *port);
ereport(FATAL,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
+
+ /*
+ * Set up a handle that child processes can use to check whether the
+ * postmaster is still running.
+ */
+ if (DuplicateHandle(GetCurrentProcess(),
+ GetCurrentProcess(),
+ GetCurrentProcess(),
+ &PostmasterHandle,
+ 0,
+ TRUE,
+ DUPLICATE_SAME_ACCESS) == 0)
+ ereport(FATAL,
+ (errmsg_internal("could not duplicate postmaster handle: %d",
+ (int) GetLastError())));
#endif
/*
write_var(debug_flag, fp);
write_var(PostmasterPid, fp);
+#ifdef WIN32
+ write_var(PostmasterHandle, fp);
+#endif
StrNCpy(str_buf, my_exec_path, MAXPGPATH);
write_array_var(str_buf, fp);
read_var(debug_flag, fp);
read_var(PostmasterPid, fp);
+#ifdef WIN32
+ read_var(PostmasterHandle, fp);
+#endif
read_array_var(str_buf, fp);
StrNCpy(my_exec_path, str_buf, MAXPGPATH);
}
ereport(WARNING,
- (errmsg_internal("unable to find backend entry with pid %d",
+ (errmsg_internal("could not find backend entry with pid %d",
(int) pid)));
}
win32_AddChild(pi.dwProcessId, pi.hProcess);
}
- if (!DuplicateHandle(GetCurrentProcess(),
- pi.hProcess,
- GetCurrentProcess(),
- &childHandleCopy,
- 0,
- FALSE,
- DUPLICATE_SAME_ACCESS))
+ if (DuplicateHandle(GetCurrentProcess(),
+ pi.hProcess,
+ GetCurrentProcess(),
+ &childHandleCopy,
+ 0,
+ FALSE,
+ DUPLICATE_SAME_ACCESS) == 0)
ereport(FATAL,
- (errmsg_internal("failed to duplicate child handle: %d",
+ (errmsg_internal("could not duplicate child handle: %d",
(int) GetLastError())));
waiterThread = CreateThread(NULL, 64 * 1024, win32_sigchld_waiter,
(LPVOID) childHandleCopy, 0, NULL);
if (!waiterThread)
ereport(FATAL,
- (errmsg_internal("failed to create sigchld waiter thread: %d",
+ (errmsg_internal("could not create sigchld waiter thread: %d",
(int) GetLastError())));
CloseHandle(waiterThread);
}
else
ereport(FATAL,
- (errmsg_internal("unable to add child entry with pid %lu",
+ (errmsg_internal("no room for child entry with pid %lu",
(unsigned long) pid)));
}
}
ereport(WARNING,
- (errmsg_internal("unable to find child entry with pid %lu",
+ (errmsg_internal("could not find child entry with pid %lu",
(unsigned long) pid)));
}
if (r == WAIT_OBJECT_0)
pg_queue_signal(SIGCHLD);
else
- fprintf(stderr, "ERROR: Failed to wait on child process handle: %i\n",
+ fprintf(stderr, "ERROR: failed to wait on child process handle: %d\n",
(int) GetLastError());
CloseHandle(procHandle);
return 0;
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/ipc/pmsignal.c,v 1.14 2004/05/29 22:48:20 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/ipc/pmsignal.c,v 1.15 2004/05/30 03:50:14 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include <unistd.h>
#include "miscadmin.h"
+#include "postmaster/postmaster.h"
#include "storage/pmsignal.h"
#include "storage/shmem.h"
return (kill(PostmasterPid, 0) == 0);
}
#else /* WIN32 */
- /*
- * XXX needs to be implemented by somebody
- */
- return true;
+ return (WaitForSingleObject(PostmasterHandle, 0) == WAIT_TIMEOUT);
#endif /* WIN32 */
}
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/postmaster/postmaster.h,v 1.1 2004/05/29 22:48:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/postmaster/postmaster.h,v 1.2 2004/05/30 03:50:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
extern bool log_hostname;
extern char *rendezvous_name;
+#ifdef WIN32
+extern HANDLE PostmasterHandle;
+#endif
+
extern int PostmasterMain(int argc, char *argv[]);
extern void ClosePostmasterPorts(void);