From 3e3f70a28ab05ec060fdbcd0bb5f819df57ba011 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Fri, 27 Aug 2004 18:31:48 +0000
Subject: [PATCH] Fix Windows emulation of kill(pid, 0).  This will now
 succeed, but only if the target PID is a PG postmaster or backend --- for our
 purposes that is actually better than the Unix behavior.  Per Dave Page and
 Andrew Dunstan.

---
 src/backend/port/win32/signal.c | 4 ++--
 src/port/kill.c                 | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/backend/port/win32/signal.c b/src/backend/port/win32/signal.c
index a5cc2561123..abde0ede3d9 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.4 2004/06/24 21:02:42 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/port/win32/signal.c,v 1.5 2004/08/27 18:31:48 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -162,7 +162,7 @@ pqsignal(int signum, pqsigfunc handler)
 void
 pg_queue_signal(int signum)
 {
-	if (signum >= PG_SIGNAL_COUNT || signum < 0)
+	if (signum >= PG_SIGNAL_COUNT || signum <= 0)
 		return;
 
 	EnterCriticalSection(&pg_signal_crit_sec);
diff --git a/src/port/kill.c b/src/port/kill.c
index ebd07d95e6c..3ef2314f20a 100644
--- a/src/port/kill.c
+++ b/src/port/kill.c
@@ -9,7 +9,7 @@
  *	signals that the backend can recognize.
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/port/kill.c,v 1.2 2004/06/24 18:53:48 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/port/kill.c,v 1.3 2004/08/27 18:31:48 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,8 @@ pgkill(int pid, int sig)
 	BYTE		sigRet = 0;
 	DWORD		bytes;
 
-	if (sig >= PG_SIGNAL_COUNT || sig <= 0)
+	/* we allow signal 0 here, but it will be ignored in pg_queue_signal */
+	if (sig >= PG_SIGNAL_COUNT || sig < 0)
 	{
 		errno = EINVAL;
 		return -1;
-- 
GitLab