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

Commit3c07fbf

Browse files
committed
Use pqsignal() in contrib programs rather than calling signal(2) directly.
The semantics of signal(2) are more variable than one could wish; inparticular, on strict-POSIX platforms the signal handler will be resetto SIG_DFL when the signal is delivered. This demonstrably breakspg_test_fsync's use of SIGALRM. The other changes I made are notabsolutely necessary today, because the called handlers all exit theprogram anyway. But it seems like a good general practice to usepqsignal() exclusively in Postgres code, now that we have it availableeverywhere.
1 parentb1fae82 commit3c07fbf

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

‎contrib/pg_standby/pg_standby.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ sighandler(int sig)
549549
staticvoid
550550
sigquit_handler(intsig)
551551
{
552-
signal(SIGINT,SIG_DFL);
552+
pqsignal(SIGINT,SIG_DFL);
553553
kill(getpid(),SIGINT);
554554
}
555555
#endif
@@ -592,9 +592,9 @@ main(int argc, char **argv)
592592
*
593593
* There's no way to trigger failover via signal on Windows.
594594
*/
595-
(void)signal(SIGUSR1,sighandler);
596-
(void)signal(SIGINT,sighandler);/* deprecated, use SIGUSR1 */
597-
(void)signal(SIGQUIT,sigquit_handler);
595+
(void)pqsignal(SIGUSR1,sighandler);
596+
(void)pqsignal(SIGINT,sighandler);/* deprecated, use SIGUSR1 */
597+
(void)pqsignal(SIGQUIT,sigquit_handler);
598598
#endif
599599

600600
while ((c=getopt(argc,argv,"cdk:lr:s:t:w:"))!=-1)

‎contrib/pg_test_fsync/pg_test_fsync.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ main(int argc, char *argv[])
101101
handle_args(argc,argv);
102102

103103
/* Prevent leaving behind the test file */
104-
signal(SIGINT,signal_cleanup);
105-
signal(SIGTERM,signal_cleanup);
104+
pqsignal(SIGINT,signal_cleanup);
105+
pqsignal(SIGTERM,signal_cleanup);
106106
#ifndefWIN32
107-
signal(SIGALRM,process_alarm);
107+
pqsignal(SIGALRM,process_alarm);
108108
#endif
109109
#ifdefSIGHUP
110110
/* Not defined on win32 */
111-
signal(SIGHUP,signal_cleanup);
111+
pqsignal(SIGHUP,signal_cleanup);
112112
#endif
113113

114114
prepare_buf();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp