Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fb489e4

Browse files
committed
In bootstrap mode, use default signal handling for SIGINT etc.
Previously, the code pointed the standard process-termination signals to postgres.c's die(). That would typically result in an attempt to execute a transaction abort, which is not possible in bootstrap mode, leading to PANIC. This choice seems to be a leftover from an old code structure in which the same signal-assignment code was used for many sorts of auxiliary processes, including interactive standalone backends. It's not very sensible for bootstrap mode, which has no interest in either interactivity or continuing after an error. We can get better behavior with less effort by just letting normal process termination happen, after which the parent initdb process will clean up. This is basically cosmetic in any case, since initdb will react the same way whether bootstrap dies on a signal or abort(). Given the lack of previous complaints, I don't feel a need to back-patch, even though the behavior is old. Discussion: https://postgr.es/m/3850b11a.5121.16aaf827e4a.Coremail.thunder1@126.com
1 parent 037165c commit fb489e4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/backend/bootstrap/bootstrap.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -558,11 +558,15 @@ bootstrap_signals(void)
558558
{
559559
Assert(!IsUnderPostmaster);
560560

561-
/* Set up appropriately for interactive use */
562-
pqsignal(SIGHUP, die);
563-
pqsignal(SIGINT, die);
564-
pqsignal(SIGTERM, die);
565-
pqsignal(SIGQUIT, die);
561+
/*
562+
* We don't actually need any non-default signal handling in bootstrap
563+
* mode; "curl up and die" is a sufficient response for all these cases.
564+
* Let's set that handling explicitly, as documentation if nothing else.
565+
*/
566+
pqsignal(SIGHUP, SIG_DFL);
567+
pqsignal(SIGINT, SIG_DFL);
568+
pqsignal(SIGTERM, SIG_DFL);
569+
pqsignal(SIGQUIT, SIG_DFL);
566570
}
567571

568572
/*

0 commit comments

Comments
 (0)