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

Skip to content

Commit 075dc25

Browse files
committed
Fix kill() call in elog() so that it gets its own pid by calling getpid().
MyProcPid global variable is set to 0 when postgres starts as a command (not as a backend daemon). This leads issuing SIGQUIT to the process group, not the process itself. As a result, parent sh gets core dumped in the Wisconsin benchmark test.
1 parent e062a17 commit 075dc25

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/backend/utils/error/elog.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.39 1999/02/13 23:19:47 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.40 1999/04/16 06:38:17 ishii Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -221,7 +221,11 @@ elog(int lev, const char *fmt,...)
221221
ProcReleaseSpins(NULL); /* get rid of spinlocks we hold */
222222
if (!InError)
223223
{
224-
kill(MyProcPid, SIGQUIT); /* abort to traffic cop */
224+
if (MyProcPid == 0) {
225+
kill(getpid(), SIGQUIT);
226+
} else {
227+
kill(MyProcPid, SIGQUIT); /* abort to traffic cop */
228+
}
225229
pause();
226230
}
227231

0 commit comments

Comments
 (0)