aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/port/win32/signal.c42
-rw-r--r--src/include/port/win32.h8
-rw-r--r--src/port/kill.c59
3 files changed, 64 insertions, 45 deletions
diff --git a/src/backend/port/win32/signal.c b/src/backend/port/win32/signal.c
index 280f10da23d..25786cfdc05 100644
--- a/src/backend/port/win32/signal.c
+++ b/src/backend/port/win32/signal.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/port/win32/signal.c,v 1.1 2004/04/12 16:19:18 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/port/win32/signal.c,v 1.2 2004/05/27 13:08:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -152,46 +152,6 @@ pqsignal(int signum, pqsigfunc handler)
return prevfunc;
}
-/* signal sending */
-int
-pqkill(int pid, int sig)
-{
- char pipename[128];
- BYTE sigData = sig;
- BYTE sigRet = 0;
- DWORD bytes;
-
- if (sig >= PG_SIGNAL_COUNT || sig <= 0)
- {
- errno = EINVAL;
- return -1;
- }
- if (pid <= 0)
- {
- /* No support for process groups */
- errno = EINVAL;
- return -1;
- }
- wsprintf(pipename, "\\\\.\\pipe\\pgsignal_%i", pid);
- if (!CallNamedPipe(pipename, &sigData, 1, &sigRet, 1, &bytes, 1000))
- {
- if (GetLastError() == ERROR_FILE_NOT_FOUND)
- errno = ESRCH;
- else if (GetLastError() == ERROR_ACCESS_DENIED)
- errno = EPERM;
- else
- errno = EINVAL;
- return -1;
- }
- if (bytes != 1 || sigRet != sig)
- {
- errno = ESRCH;
- return -1;
- }
-
- return 0;
-}
-
/*
* All functions below execute on the signal handler thread
* and must be synchronized as such!
diff --git a/src/include/port/win32.h b/src/include/port/win32.h
index 03bc7a75b98..851516ba850 100644
--- a/src/include/port/win32.h
+++ b/src/include/port/win32.h
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.23 2004/04/22 03:51:24 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.24 2004/05/27 13:08:54 momjian Exp $ */
/* undefine and redefine after #include */
#undef mkdir
@@ -116,10 +116,10 @@ void pg_queue_signal(int signum);
#define SIG_ERR ((pqsigfunc)-1)
#define SIG_IGN ((pqsigfunc)1)
-#ifndef FRONTEND
-#define kill(pid,sig) pqkill(pid,sig)
-extern int pqkill(int pid, int sig);
+#define kill(pid,sig) pgkill(pid,sig)
+extern int pgkill(int pid, int sig);
+#ifndef FRONTEND
#define pg_usleep(t) pgwin32_backend_usleep(t)
void pgwin32_backend_usleep(long microsec);
#endif
diff --git a/src/port/kill.c b/src/port/kill.c
new file mode 100644
index 00000000000..b13fea924f7
--- /dev/null
+++ b/src/port/kill.c
@@ -0,0 +1,59 @@
+/*-------------------------------------------------------------------------
+ *
+ * kill.c
+ * kill()
+ *
+ * Copyright (c) 1996-2003, PostgreSQL Global Development Group
+ *
+ * This is a replacement version of kill for Win32 which sends
+ * signals that the backend can recognize.
+ *
+ * IDENTIFICATION
+ * $PostgreSQL: pgsql/src/port/kill.c,v 1.1 2004/05/27 13:08:57 momjian Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#include "postgres.h"
+
+#ifdef WIN32
+/* signal sending */
+int
+pgkill(int pid, int sig)
+{
+ char pipename[128];
+ BYTE sigData = sig;
+ BYTE sigRet = 0;
+ DWORD bytes;
+
+ if (sig >= PG_SIGNAL_COUNT || sig <= 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ if (pid <= 0)
+ {
+ /* No support for process groups */
+ errno = EINVAL;
+ return -1;
+ }
+ wsprintf(pipename, "\\\\.\\pipe\\pgsignal_%i", pid);
+ if (!CallNamedPipe(pipename, &sigData, 1, &sigRet, 1, &bytes, 1000))
+ {
+ if (GetLastError() == ERROR_FILE_NOT_FOUND)
+ errno = ESRCH;
+ else if (GetLastError() == ERROR_ACCESS_DENIED)
+ errno = EPERM;
+ else
+ errno = EINVAL;
+ return -1;
+ }
+ if (bytes != 1 || sigRet != sig)
+ {
+ errno = ESRCH;
+ return -1;
+ }
+
+ return 0;
+}
+#endif