Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3e3f70a

Browse files
committed
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.
1 parent 1785ace commit 3e3f70a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/backend/port/win32/signal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/port/win32/signal.c,v 1.4 2004/06/24 21:02:42 tgl Exp $
9+
* $PostgreSQL: pgsql/src/backend/port/win32/signal.c,v 1.5 2004/08/27 18:31:48 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -162,7 +162,7 @@ pqsignal(int signum, pqsigfunc handler)
162162
void
163163
pg_queue_signal(int signum)
164164
{
165-
if (signum >= PG_SIGNAL_COUNT || signum < 0)
165+
if (signum >= PG_SIGNAL_COUNT || signum <= 0)
166166
return;
167167

168168
EnterCriticalSection(&pg_signal_crit_sec);

src/port/kill.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* signals that the backend can recognize.
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/port/kill.c,v 1.2 2004/06/24 18:53:48 tgl Exp $
12+
* $PostgreSQL: pgsql/src/port/kill.c,v 1.3 2004/08/27 18:31:48 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -26,7 +26,8 @@ pgkill(int pid, int sig)
2626
BYTE sigRet = 0;
2727
DWORD bytes;
2828

29-
if (sig >= PG_SIGNAL_COUNT || sig <= 0)
29+
/* we allow signal 0 here, but it will be ignored in pg_queue_signal */
30+
if (sig >= PG_SIGNAL_COUNT || sig < 0)
3031
{
3132
errno = EINVAL;
3233
return -1;

0 commit comments

Comments
 (0)