Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4bd9de3

Browse files
committed
Fix elog(FATAL) before PostmasterMain() or just after fork().
Since commit97550c0, these failed with"PANIC: proc_exit() called in child process" due to uninitialized orstale MyProcPid. That was reachable if close() failed inClosePostmasterPorts() or setlocale(category, "C") failed, bothunlikely. Back-patch to v13 (all supported versions).Discussion:https://postgr.es/m/20241208034614.45.nmisch@google.com
1 parent67ef403 commit4bd9de3

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

‎src/backend/main/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include"bootstrap/bootstrap.h"
3434
#include"common/username.h"
35+
#include"miscadmin.h"
3536
#include"port/atomics.h"
3637
#include"postmaster/postmaster.h"
3738
#include"tcop/tcopprot.h"
@@ -96,6 +97,7 @@ main(int argc, char *argv[])
9697
* localization of messages may not work right away, and messages won't go
9798
* anywhere but stderr until GUC settings get loaded.
9899
*/
100+
MyProcPid=getpid();
99101
MemoryContextInit();
100102

101103
/*

‎src/backend/postmaster/fork_process.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include<unistd.h>
2020

2121
#include"libpq/pqsignal.h"
22+
#include"miscadmin.h"
2223
#include"postmaster/fork_process.h"
2324

2425
#ifndefWIN32
@@ -66,6 +67,7 @@ fork_process(void)
6667
if (result==0)
6768
{
6869
/* fork succeeded, in child */
70+
MyProcPid=getpid();
6971
#ifdefLINUX_PROFILE
7072
setitimer(ITIMER_PROF,&prof_itimer,NULL);
7173
#endif

‎src/backend/postmaster/postmaster.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,14 +2024,13 @@ ClosePostmasterPorts(bool am_syslogger)
20242024

20252025

20262026
/*
2027-
* InitProcessGlobals -- setMyProcPid,MyStartTime[stamp], random seeds
2027+
* InitProcessGlobals -- set MyStartTime[stamp], random seeds
20282028
*
20292029
* Called early in the postmaster and every backend.
20302030
*/
20312031
void
20322032
InitProcessGlobals(void)
20332033
{
2034-
MyProcPid=getpid();
20352034
MyStartTimestamp=GetCurrentTimestamp();
20362035
MyStartTime=timestamptz_to_time_t(MyStartTimestamp);
20372036

‎src/port/pqsignal.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ static volatile pqsigfunc pqsignal_handlers[PG_NSIG];
7474
/*
7575
* Except when called with SIG_IGN or SIG_DFL, pqsignal() sets up this function
7676
* as the handler for all signals. This wrapper handler function checks that
77-
* it is called within a process that the server knows about (i.e., any process
78-
* that has called InitProcessGlobals(), such as a client backend), and not a
77+
* it is called within a process that knew to maintain MyProcPid, and not a
7978
* child process forked by system(3), etc. This check ensures that such child
8079
* processes do not modify shared memory, which is often detrimental. If the
8180
* check succeeds, the function originally provided to pqsignal() is called.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp