Leave SIGTTIN/SIGTTOU signal handling alone in postmaster child processes.
For reasons lost in the mists of time, most postmaster child processes reset SIGTTIN/SIGTTOU signal handling to SIG_DFL, with the major exception that backend sessions do not. It seems like a pretty bad idea for any postmaster children to do that: if stderr is connected to the terminal, and the user has put the postmaster in background, any log output would result in the child process freezing up. Hence, switch them all to doing what backends do, ie, nothing. This allows them to inherit the postmaster's SIG_IGN setting. On the other hand, manually-launched processes such as standalone backends will have default processing, which seems fine. In passing, also remove useless resets of SIGCONT and SIGWINCH signal processing. Perhaps the postmaster once changed those to something besides SIG_DFL, but it doesn't now, so these are just wasted (and confusing) syscalls. Basically, this propagates the changes made in commit 8e2998d8a from backends to other postmaster children. Probably the only reason these calls now exist elsewhere is that I missed changing pgstat.c along with postgres.c at the time. Given the lack of field complaints that can be traced to this, I don't presently feel a need to back-patch. Discussion: https://postgr.es/m/5627.1542477392@sss.pgh.pa.us
This commit is contained in:
parent
73616126b4
commit
125f551c8b
@ -133,10 +133,6 @@ BackgroundWriterMain(void)
|
||||
* Reset some signals that are accepted by postmaster but not here
|
||||
*/
|
||||
pqsignal(SIGCHLD, SIG_DFL);
|
||||
pqsignal(SIGTTIN, SIG_DFL);
|
||||
pqsignal(SIGTTOU, SIG_DFL);
|
||||
pqsignal(SIGCONT, SIG_DFL);
|
||||
pqsignal(SIGWINCH, SIG_DFL);
|
||||
|
||||
/* We allow SIGQUIT (quickdie) at all times */
|
||||
sigdelset(&BlockSig, SIGQUIT);
|
||||
|
@ -218,10 +218,6 @@ CheckpointerMain(void)
|
||||
* Reset some signals that are accepted by postmaster but not here
|
||||
*/
|
||||
pqsignal(SIGCHLD, SIG_DFL);
|
||||
pqsignal(SIGTTIN, SIG_DFL);
|
||||
pqsignal(SIGTTOU, SIG_DFL);
|
||||
pqsignal(SIGCONT, SIG_DFL);
|
||||
pqsignal(SIGWINCH, SIG_DFL);
|
||||
|
||||
/* We allow SIGQUIT (quickdie) at all times */
|
||||
sigdelset(&BlockSig, SIGQUIT);
|
||||
|
@ -226,11 +226,8 @@ PgArchiverMain(int argc, char *argv[])
|
||||
pqsignal(SIGPIPE, SIG_IGN);
|
||||
pqsignal(SIGUSR1, pgarch_waken);
|
||||
pqsignal(SIGUSR2, pgarch_waken_stop);
|
||||
/* Reset some signals that are accepted by postmaster but not here */
|
||||
pqsignal(SIGCHLD, SIG_DFL);
|
||||
pqsignal(SIGTTIN, SIG_DFL);
|
||||
pqsignal(SIGTTOU, SIG_DFL);
|
||||
pqsignal(SIGCONT, SIG_DFL);
|
||||
pqsignal(SIGWINCH, SIG_DFL);
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
|
||||
/*
|
||||
|
@ -4267,11 +4267,8 @@ PgstatCollectorMain(int argc, char *argv[])
|
||||
pqsignal(SIGPIPE, SIG_IGN);
|
||||
pqsignal(SIGUSR1, SIG_IGN);
|
||||
pqsignal(SIGUSR2, SIG_IGN);
|
||||
/* Reset some signals that are accepted by postmaster but not here */
|
||||
pqsignal(SIGCHLD, SIG_DFL);
|
||||
pqsignal(SIGTTIN, SIG_DFL);
|
||||
pqsignal(SIGTTOU, SIG_DFL);
|
||||
pqsignal(SIGCONT, SIG_DFL);
|
||||
pqsignal(SIGWINCH, SIG_DFL);
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
|
||||
/*
|
||||
|
@ -646,8 +646,17 @@ PostmasterMain(int argc, char *argv[])
|
||||
pqsignal_no_restart(SIGUSR2, dummy_handler); /* unused, reserve for
|
||||
* children */
|
||||
pqsignal_no_restart(SIGCHLD, reaper); /* handle child termination */
|
||||
|
||||
/*
|
||||
* No other place in Postgres should touch SIGTTIN/SIGTTOU handling. We
|
||||
* ignore those signals in a postmaster environment, so that there is no
|
||||
* risk of a child process freezing up due to writing to stderr. But for
|
||||
* a standalone backend, their default handling is reasonable. Hence, all
|
||||
* child processes should just allow the inherited settings to stand.
|
||||
*/
|
||||
pqsignal(SIGTTIN, SIG_IGN); /* ignored */
|
||||
pqsignal(SIGTTOU, SIG_IGN); /* ignored */
|
||||
|
||||
/* ignore SIGXFSZ, so that ulimit violations work like disk full */
|
||||
#ifdef SIGXFSZ
|
||||
pqsignal(SIGXFSZ, SIG_IGN); /* ignored */
|
||||
|
@ -188,10 +188,6 @@ StartupProcessMain(void)
|
||||
* Reset some signals that are accepted by postmaster but not here
|
||||
*/
|
||||
pqsignal(SIGCHLD, SIG_DFL);
|
||||
pqsignal(SIGTTIN, SIG_DFL);
|
||||
pqsignal(SIGTTOU, SIG_DFL);
|
||||
pqsignal(SIGCONT, SIG_DFL);
|
||||
pqsignal(SIGWINCH, SIG_DFL);
|
||||
|
||||
/*
|
||||
* Register timeouts needed for standby mode
|
||||
|
@ -257,10 +257,6 @@ SysLoggerMain(int argc, char *argv[])
|
||||
* Reset some signals that are accepted by postmaster but not here
|
||||
*/
|
||||
pqsignal(SIGCHLD, SIG_DFL);
|
||||
pqsignal(SIGTTIN, SIG_DFL);
|
||||
pqsignal(SIGTTOU, SIG_DFL);
|
||||
pqsignal(SIGCONT, SIG_DFL);
|
||||
pqsignal(SIGWINCH, SIG_DFL);
|
||||
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
|
||||
|
@ -121,10 +121,6 @@ WalWriterMain(void)
|
||||
* Reset some signals that are accepted by postmaster but not here
|
||||
*/
|
||||
pqsignal(SIGCHLD, SIG_DFL);
|
||||
pqsignal(SIGTTIN, SIG_DFL);
|
||||
pqsignal(SIGTTOU, SIG_DFL);
|
||||
pqsignal(SIGCONT, SIG_DFL);
|
||||
pqsignal(SIGWINCH, SIG_DFL);
|
||||
|
||||
/* We allow SIGQUIT (quickdie) at all times */
|
||||
sigdelset(&BlockSig, SIGQUIT);
|
||||
|
@ -279,10 +279,6 @@ WalReceiverMain(void)
|
||||
|
||||
/* Reset some signals that are accepted by postmaster but not here */
|
||||
pqsignal(SIGCHLD, SIG_DFL);
|
||||
pqsignal(SIGTTIN, SIG_DFL);
|
||||
pqsignal(SIGTTOU, SIG_DFL);
|
||||
pqsignal(SIGCONT, SIG_DFL);
|
||||
pqsignal(SIGWINCH, SIG_DFL);
|
||||
|
||||
/* We allow SIGQUIT (quickdie) at all times */
|
||||
sigdelset(&BlockSig, SIGQUIT);
|
||||
|
@ -3003,10 +3003,6 @@ WalSndSignals(void)
|
||||
|
||||
/* Reset some signals that are accepted by postmaster but not here */
|
||||
pqsignal(SIGCHLD, SIG_DFL);
|
||||
pqsignal(SIGTTIN, SIG_DFL);
|
||||
pqsignal(SIGTTOU, SIG_DFL);
|
||||
pqsignal(SIGCONT, SIG_DFL);
|
||||
pqsignal(SIGWINCH, SIG_DFL);
|
||||
}
|
||||
|
||||
/* Report shared-memory space needed by WalSndShmemInit */
|
||||
|
Loading…
x
Reference in New Issue
Block a user