Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
This PR simplifies Windows-specific signal/console-control handling in the test server utilities by removing preprocessor guards around SIG* macros, based on the assumption that these macros are available in all supported Windows toolchains.
Changes:
- Remove
#ifdef SIGINT/SIGTERM/SIGBREAKguards inctrl_event_handler()switch cases. - Remove
#ifdef SIGTERMguard forWM_CLOSEhandling inmain_window_proc(). - Broaden SIGBREAK handler install/restore guards from
defined(SIGBREAK) && defined(_WIN32)to just_WIN32.
Suppressed comments (3)
tests/server/util.c:480
- main_window_proc() now uses SIGTERM unconditionally for WM_CLOSE, but SIGTERM is still guarded elsewhere in this file. Keeping SIGTERM optional here avoids compilation failures on platforms/toolchains where SIGTERM is not available.
switch(uMsg) {
case WM_CLOSE:
signum = SIGTERM;
break;
tests/server/util.c:632
- install_signal_handlers() now enters the SIGBREAK setup under just _WIN32, but old_sigbreak_handler is still conditionally defined under
#if defined(SIGBREAK) && defined(_WIN32)earlier in this file. If SIGBREAK is not defined, this becomes a build break; keeping the SIGBREAK-specific code guarded avoids that inconsistency.
#ifdef _WIN32
/* handle SIGBREAK signal with our exit_signal_handler */
old_sigbreak_handler = set_signal(SIGBREAK, exit_signal_handler, 1);
if(old_sigbreak_handler == SIG_ERR)
logmsg("cannot install SIGBREAK handler: (%d) %s",
tests/server/util.c:675
- restore_signal_handlers() now restores SIGBREAK unconditionally under _WIN32, but the saved old_sigbreak_handler is only defined when SIGBREAK is available. Guard the restore with SIGBREAK to avoid compilation failures and keep the preprocessor logic consistent.
#ifdef _WIN32
if(old_sigbreak_handler != SIG_ERR)
(void)set_signal(SIGBREAK, old_sigbreak_handler, 0);
(void)SetConsoleCtrlHandler(ctrl_event_handler, FALSE);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These
SIG*macro are provided by all supported Windows toolchains.Cherry-picked from #22487