diff --git a/configure b/configure index 8a882dffc8..053144e8f0 100755 --- 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 diff --git a/configure.in b/configure.in index fc2825c9b2..70b83da76f 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/src/backend/port/win32/signal.c b/src/backend/port/win32/signal.c index 280f10da23..25786cfdc0 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 03bc7a75b9..851516ba85 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 0000000000..b13fea924f --- /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