diff options
| author | Andreas Gruenbacher <agruenba@redhat.com> | 2016-02-01 10:46:58 +0100 |
|---|---|---|
| committer | Michael Kerrisk <mtk.manpages@gmail.com> | 2016-02-01 15:21:41 +0100 |
| commit | 148c6e74c00b041d5fc3e96dec44410b8c3c6dbe (patch) | |
| tree | 74017e8a45212e28887b19c3f8de23c64c0b4cfd /man7/aio.7 | |
| parent | 555c23c278cc46f3331859e71ddace24be04d717 (diff) | |
| download | man-pages-148c6e74c00b041d5fc3e96dec44410b8c3c6dbe.tar.gz | |
aio.7: Improve example
When aio_sigevent.sigev_notify is set to SIGEV_SIGNAL, signal
handlers called for asynchronous I/O operations will have
si->si_code set to SI_ASYNCIO. Check to make sure that
si->si_value.sival_ptr is defined.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Diffstat (limited to 'man7/aio.7')
| -rw-r--r-- | man7/aio.7 | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/man7/aio.7 b/man7/aio.7 index b150a2615c..275c0b7639 100644 --- a/man7/aio.7 +++ b/man7/aio.7 @@ -282,12 +282,14 @@ quitHandler(int sig) static void /* Handler for I/O completion signal */ aioSigHandler(int sig, siginfo_t *si, void *ucontext) { - write(STDOUT_FILENO, "I/O completion signal received\\n", 31); + if (si->si_code == SI_ASYNCIO) { + write(STDOUT_FILENO, "I/O completion signal received\\n", 31); - /* The corresponding ioRequest structure would be available as - struct ioRequest *ioReq = si\->si_value.sival_ptr; - and the file descriptor would then be available via - ioReq\->aiocbp\->aio_fildes */ + /* The corresponding ioRequest structure would be available as + struct ioRequest *ioReq = si\->si_value.sival_ptr; + and the file descriptor would then be available via + ioReq\->aiocbp\->aio_fildes */ + } } int |
