Skip to content

[codex] add POSIX signal wake service - #10

Merged
LimiNode merged 1 commit into
mainfrom
codex/posix-signal-wake-service
Jun 9, 2026
Merged

[codex] add POSIX signal wake service#10
LimiNode merged 1 commit into
mainfrom
codex/posix-signal-wake-service

Conversation

@LimiNode

@LimiNode LimiNode commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary

Adds an opt-in POSIX self-pipe wake bridge so SIGINT/SIGTERM can wake throttled Consolix polling loops without doing mutex or condition-variable work inside a signal handler.

What Changed

  • Added PosixSignalWakeService in core.
    • Maintains a self-pipe and watcher thread on POSIX platforms.
    • Exposes an async-signal-safe hook used by the existing runner signal handler.
    • Wakes LoopWakeService from ordinary C++ code after the signal handler writes to the pipe.
    • Compiles as a no-op on Windows.
  • Added PosixSignalWakeComponent in components.
    • Starts/stops the service through the existing component lifecycle.
    • Lets applications opt in with consolix::add<consolix::PosixSignalWakeComponent>().
  • Kept ConsoleApplicationRunner as the owner of POSIX signal handler registration.
    • The handler still stores the signal in sig_atomic_t.
    • When the opt-in service is active, it also writes one byte to the self-pipe.
  • Extended the POSIX shutdown test with a long LoopThrottleComponent delay so Linux/macOS CI verifies that SIGINT/SIGTERM interrupts the throttle wait quickly.
  • Documented the opt-in component in README, README-RU, and Doxygen mainpage docs.

Why

The previous runner behavior was intentionally async-signal-safe on POSIX, but a long LoopThrottleComponent delay could postpone SIGINT/SIGTERM handling until the throttle wait ended.

The self-pipe bridge keeps the unsafe work out of the signal handler while still waking the polling loop promptly. The runner signal handler writes one byte to a pipe, and the watcher thread wakes LoopWakeService, allowing the normal runner loop to observe the already-recorded stop request.

Validation

  • cmake --build tmp/agent-work/build-runner-mingw --parallel 1
  • ctest --test-dir tmp/agent-work/build-runner-mingw --output-on-failure -> 7/7 passed
  • cmake --build tmp/agent-work/build-runner-cxx11-mingw --parallel 1
  • ctest --test-dir tmp/agent-work/build-runner-cxx11-mingw --output-on-failure -> 5/5 passed
  • rg -n '^\\s*#include .*\\.\\./' include -> no matches
  • git diff --cached --check

POSIX self-pipe behavior is covered by tests/test_posix_signal_shutdown.cpp and is expected to run in Linux/macOS CI.

@LimiNode
LimiNode marked this pull request as ready for review June 9, 2026 07:12
@LimiNode
LimiNode merged commit a517106 into main Jun 9, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant