Skip to content

servers: drop redundant guards on Windows - #22493

Closed
vszakats wants to merge 3 commits into
curl:masterfrom
vszakats:w-servers-redundant-guards
Closed

vszakats wants to merge 3 commits into
curl:masterfrom
vszakats:w-servers-redundant-guards

Conversation

@vszakats

@vszakats vszakats commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

These SIG* macro are provided by all supported Windows toolchains.

Cherry-picked from #22487

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/SIGBREAK guards in ctrl_event_handler() switch cases.
  • Remove #ifdef SIGTERM guard for WM_CLOSE handling in main_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.

Comment thread tests/server/util.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@vszakats vszakats closed this in 947ae0e Aug 5, 2026
@vszakats
vszakats deleted the w-servers-redundant-guards branch August 5, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants