menios
menios copied to clipboard
Implement advanced signal features (SIGCHLD, SA_RESTART, vDSO, RT signals)
Description
This is Part 5 of 5 for implementing UNIX signals (see #103). This issue covers advanced signal features for complete POSIX compatibility.
Scope
Implement advanced signal functionality:
-
SIGCHLDfor waitpid notification -
SA_RESTARTflag for interrupted syscalls - Stack-based signal trampoline (vDSO)
- Signal masks per thread (for multithreaded processes)
- Real-time signals (
SIGRTMIN-SIGRTMAX)
Implementation Notes
SIGCHLD Support:
- Sent to parent when child exits or stops
- Parent can register handler to reap zombies asynchronously
-
waitpid()can be called from handler - Avoids polling for child status
SA_RESTART:
- Restarts interrupted syscalls automatically
- Syscalls like
read(),write()resume after signal handler - Some syscalls (
accept(),sleep()) never restart
Signal Trampoline in vDSO:
- Current: trampoline code on stack (security issue)
- Better: trampoline in vDSO (virtual dynamic shared object)
- Maps read-only page into all processes
- Contains
sigreturnstub
Per-Thread Signal Masks:
- Each thread has own
sig_blockedmask -
pthread_sigmask()for thread-specific blocking - Signals can target specific threads
- Process-wide signals delivered to any unblocked thread
Real-Time Signals:
-
SIGRTMIN(34) toSIGRTMAX(64) - Queued (not merged like standard signals)
- Delivered in order
- Can carry payload (
sigqueue())
Acceptance Criteria
- [ ]
SIGCHLDsent when child exits - [ ]
SA_RESTARTrestarts interrupted syscalls - [ ] Signal trampoline in vDSO (more secure)
- [ ] Per-thread signal masks work correctly
- [ ] Real-time signals are queued and ordered
- [ ] Comprehensive test suite for all features
- [ ] Documentation covers all advanced features
Dependencies
Depends on:
- #213 - Shell signal integration (Part 4)
- #109 - pthread API (for per-thread masks)
Related Issues
- #103 - Parent issue for full signal implementation
- #210-#213 - Parts 1-4 of signal implementation
- #145 - waitpid implementation (needs
SIGCHLD)
Known Future Work
- Job control signals (
SIGTSTP,SIGCONT,SIGTTIN,SIGTTOU) - Signal safety (async-signal-safe function list)
-
signalfd()for event-driven signal handling -
sigwaitinfo(),sigtimedwait()
Estimated effort: 3-4 weeks Priority: Medium (nice to have, not blocking)