Move pgkill out into /port so pg_ctl can use it on Win32.
authorBruce Momjian
Thu, 27 May 2004 13:08:57 +0000 (13:08 +0000)
committerBruce Momjian
Thu, 27 May 2004 13:08:57 +0000 (13:08 +0000)
configure
configure.in
src/backend/port/win32/signal.c
src/include/port/win32.h
src/port/kill.c [new file with mode: 0644]

index 8a882dffc84ca3066be29d154e4737328a2e793d..053144e8f0fdf850bd0c73d0b4e60f0c90594f40 100755 (executable)
--- a/configure
+++ b/configure
@@ -12014,6 +12014,7 @@ esac
 case $host_os in mingw*)
 LIBOBJS="$LIBOBJS copydir.$ac_objext"
 LIBOBJS="$LIBOBJS gettimeofday.$ac_objext"
+LIBOBJS="$LIBOBJS kill.$ac_objext"
 LIBOBJS="$LIBOBJS open.$ac_objext"
 LIBOBJS="$LIBOBJS rand.$ac_objext" ;;
 esac
index fc2825c9b234ccb2aa7428a570f2452facb5918a..70b83da76fe17ab4c8edd7042a1b4fe2345e4416 100644 (file)
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-dnl $PostgreSQL: pgsql/configure.in,v 1.358 2004/05/22 00:34:49 tgl Exp $
+dnl $PostgreSQL: pgsql/configure.in,v 1.359 2004/05/27 13:08:48 momjian Exp $
 dnl
 dnl Developers, please strive to achieve this order:
 dnl
@@ -891,6 +891,7 @@ esac
 case $host_os in mingw*)
 AC_LIBOBJ(copydir)
 AC_LIBOBJ(gettimeofday)
+AC_LIBOBJ(kill)
 AC_LIBOBJ(open)
 AC_LIBOBJ(rand) ;;
 esac
index 280f10da23d32740b4492f7e1e9280b3d08f5443..25786cfdc051d6fb98c1c4f521834fadea4d23c4 100644 (file)
@@ -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!
index 03bc7a75b989c16c64dda4c2f9f876b6e254e2d7..851516ba8504c35c574cc9e599616d68ef15721d 100644 (file)
@@ -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 (file)
index 0000000..b13fea9
--- /dev/null
@@ -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