fasync and SIGIO¶
fasync allows a driver to notify a user-space process asynchronously by sending SIGIO. This is another notification model besides blocking read(), poll, and epoll.
Basic Flow¶
user space sets F_SETOWN
↓
user space enables O_ASYNC
↓
driver .fasync callback registers file
↓
driver event occurs
↓
kill_fasync(..., SIGIO, POLL_IN)
↓
user-space SIGIO handler runs
When It Is Useful¶
SIGIO can be useful for simple asynchronous notification, but it is usually less structured than fd-based event loops.
In this repo, SIGIO was later bridged into an eventfd so the final user-space architecture could still use epoll.
Driver-Side Components¶
| Component | Purpose |
|---|---|
.fasync |
Registers or unregisters async notification target |
fasync_helper() |
Maintains async notification list |
kill_fasync() |
Sends SIGIO to registered process |
Common Pitfalls¶
Warning
Signal handlers should do as little work as possible. Writing to eventfd is a safer pattern than doing complex processing inside the handler.
Warning
SIGIO is process-signal based, while epoll is fd-based. Mixing both models requires careful design.