Skip to content

Add signal handling #38

@AlexJuca

Description

@AlexJuca

Context

Production processes must shut down cleanly under SIGINT/SIGTERM and must not do unsafe work directly inside signal handlers. FKVS currently needs a coordinated shutdown path that works across epoll, kqueue, and io_uring.

Related: #78 tracks concrete cleanup and memory-release correctness.

Scope

  • Support SIGINT and SIGTERM.
  • Make signal handlers async-signal-safe: set a shutdown flag or wake the event loop, then return.
  • Let the event loop stop accepting new clients and drain/close existing clients according to documented semantics.
  • Flush or intentionally discard pending responses consistently.
  • Coordinate with persistence work so snapshots/AOF flushes happen outside the signal handler.
  • Clean up TCP listener, Unix domain socket path, event-loop fd, client list, and database memory.

Acceptance criteria

  • kill -TERM <pid> exits cleanly with status 0 or documented shutdown status.
  • Shutdown does not call malloc/free/printf/list traversal from the signal handler.
  • Shutdown behavior is covered by integration tests or a documented CI-safe smoke test.
  • Leak/sanitizer runs do not report shutdown leaks attributable to normal server lifecycle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions