Signal Handling API for Systems Programming #288
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
refactor
rust
technical-debt
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
navicore/patch-seq#288
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Motivation
Seq aims to support systems programming, where signal handling is essential for:
Currently, Seq has a default SIGINT handler that exits on Ctrl-C (#287). This issue explores a user-facing API for customizing signal behavior.
Design Constraints
1. Async-Signal-Safety
Signal handlers execute in an interrupt context with severe restrictions:
2. Stack-Based Paradigm
The API should feel natural in Seq's concatenative style.
3. May Scheduler Integration
Signals and coroutines need careful coordination.
4. Cross-Platform
Proposed API Options
Option A: Flag-Based (Recommended for v1)
Simple, safe, fits the "check in your event loop" pattern:
Pros:
Cons:
Option B: Channel-Based (Advanced)
Signals delivered as messages on a channel:
Pros:
Cons:
Option C: Hybrid Approach (Recommended for v2)
Combine both for flexibility:
Implementation Sketch
Flag-Based Core
Signal Constants
Use Cases
1. Graceful HTTP Server Shutdown
2. Config Reload on SIGHUP
3. Worker Process Management
Open Questions
Signal masking during critical sections?
sigaction vs signal?
sigactionis more portable and allows SA_RESTARTReal-time signals (SIGRTMIN+n)?
Windows support?
Integration with weaves/strands?
signal.waitbe a yielding operation?Milestones
v1: Basic Flag API
signal.trap,signal.received?,signal.pending?signal.default,signal.ignorev2: Channel API
signal.channelfor async handlingchannel.selectv3: Advanced
signal.block,signal.unblock)sigactionflags (SA_RESTART, etc.)References
https://github.com/navicore/patch-seq/pull/291