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

Commit5cda4fd

Browse files
Avoid calling pqsignal() with invalid signals on Windows frontends.
As noted by the comment at the top of port/pqsignal.c, Windowsfrontend programs can only use pqsignal() with the 6 signalsrequired by C. Most places avoid using invalid signals via #ifndefWIN32, but initdb and pg_test_fsync check whether the signal itselfis defined, which doesn't work because win32_port.h defines manyextra signals for the signal emulation code. pg_regress seems tohave missed the memo completely. These issues aren't causing anyreal problems today because nobody checks the return value ofpqsignal(), but a follow-up commit will add some error checking.To fix, surround all frontend calls to pqsignal() that use signalsthat are invalid on Windows with #ifndef WIN32. We cannot simplyskip defining the extra signals in win32_port.h for frontendsbecause they are needed in places such as pgkill().Reviewed-by: Thomas MunroDiscussion:https://postgr.es/m/Z4chOKfnthRH71mw%40nathan
1 parentd7674c9 commit5cda4fd

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

‎src/bin/initdb/initdb.c‎

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,27 +2874,18 @@ setup_text_search(void)
28742874
void
28752875
setup_signals(void)
28762876
{
2877-
/* some of these are not valid on Windows */
2878-
#ifdefSIGHUP
2879-
pqsignal(SIGHUP,trapsig);
2880-
#endif
2881-
#ifdefSIGINT
28822877
pqsignal(SIGINT,trapsig);
2883-
#endif
2884-
#ifdefSIGQUIT
2885-
pqsignal(SIGQUIT,trapsig);
2886-
#endif
2887-
#ifdefSIGTERM
28882878
pqsignal(SIGTERM,trapsig);
2889-
#endif
2879+
2880+
/* the following are not valid on Windows */
2881+
#ifndefWIN32
2882+
pqsignal(SIGHUP,trapsig);
2883+
pqsignal(SIGQUIT,trapsig);
28902884

28912885
/* Ignore SIGPIPE when writing to backend, so we can clean up */
2892-
#ifdefSIGPIPE
28932886
pqsignal(SIGPIPE,SIG_IGN);
2894-
#endif
28952887

28962888
/* Prevent SIGSYS so we can probe for kernel calls that might not work */
2897-
#ifdefSIGSYS
28982889
pqsignal(SIGSYS,SIG_IGN);
28992890
#endif
29002891
}

‎src/bin/pg_test_fsync/pg_test_fsync.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,10 @@ main(int argc, char *argv[])
112112
/* Prevent leaving behind the test file */
113113
pqsignal(SIGINT,signal_cleanup);
114114
pqsignal(SIGTERM,signal_cleanup);
115+
116+
/* the following are not valid on Windows */
115117
#ifndefWIN32
116118
pqsignal(SIGALRM,process_alarm);
117-
#endif
118-
#ifdefSIGHUP
119-
/* Not defined on win32 */
120119
pqsignal(SIGHUP,signal_cleanup);
121120
#endif
122121

‎src/test/regress/pg_regress.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,11 +518,15 @@ make_temp_sockdir(void)
518518
* Remove the directory before dying to the usual signals. Omit SIGQUIT,
519519
* preserving it as a quick, untidy exit.
520520
*/
521-
pqsignal(SIGHUP,signal_remove_temp);
522521
pqsignal(SIGINT,signal_remove_temp);
523-
pqsignal(SIGPIPE,signal_remove_temp);
524522
pqsignal(SIGTERM,signal_remove_temp);
525523

524+
/* the following are not valid on Windows */
525+
#ifndefWIN32
526+
pqsignal(SIGHUP,signal_remove_temp);
527+
pqsignal(SIGPIPE,signal_remove_temp);
528+
#endif
529+
526530
returntemp_sockdir;
527531
}
528532

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp