All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] aio.7: Improve example
@ 2016-02-01  9:46 Andreas Gruenbacher
       [not found] ` <1454320018-14176-1-git-send-email-agruenba-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Gruenbacher @ 2016-02-01  9:46 UTC (permalink / raw)
  To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w
  Cc: Andreas Gruenbacher, linux-man-u79uwXL29TY76Z2rM5mHXA

When aio_sigevent.sigev_notify is set to SIGEV_SIGNAL, signal handlers
called for asychronous 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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 aio.7 | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/aio.7 b/aio.7
index 1f861da..21193fd 100644
--- a/aio.7
+++ b/aio.7
@@ -281,12 +281,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
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] aio.7: Improve example
       [not found] ` <1454320018-14176-1-git-send-email-agruenba-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2016-02-01 12:09   ` walter harms
       [not found]     ` <56AF4AF9.9000807-fPG8STNUNVg@public.gmane.org>
  2016-02-01 14:23   ` Michael Kerrisk (man-pages)
  1 sibling, 1 reply; 4+ messages in thread
From: walter harms @ 2016-02-01 12:09 UTC (permalink / raw)
  To: Andreas Gruenbacher
  Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w, linux-man-u79uwXL29TY76Z2rM5mHXA



Am 01.02.2016 10:46, schrieb Andreas Gruenbacher:
> When aio_sigevent.sigev_notify is set to SIGEV_SIGNAL, signal handlers
> called for asychronous 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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
>  aio.7 | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/aio.7 b/aio.7
> index 1f861da..21193fd 100644
> --- a/aio.7
> +++ b/aio.7
> @@ -281,12 +281,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);

what about the replace write with dprintf ? dprintf is POSIX since 2008.

re,
 wh

>  
> -    /* 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
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] aio.7: Improve example
       [not found] ` <1454320018-14176-1-git-send-email-agruenba-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2016-02-01 12:09   ` walter harms
@ 2016-02-01 14:23   ` Michael Kerrisk (man-pages)
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Kerrisk (man-pages) @ 2016-02-01 14:23 UTC (permalink / raw)
  To: Andreas Gruenbacher
  Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w, linux-man-u79uwXL29TY76Z2rM5mHXA

Hi Andreas,

On 02/01/2016 10:46 AM, Andreas Gruenbacher wrote:
> When aio_sigevent.sigev_notify is set to SIGEV_SIGNAL, signal handlers
> called for asychronous I/O operations will have si->si_code set to
> SI_ASYNCIO.  Check to make sure that si->si_value.sival_ptr is defined.

Thanks. Applied.

Cheers,

Michael


> Signed-off-by: Andreas Gruenbacher <agruenba-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
>  aio.7 | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/aio.7 b/aio.7
> index 1f861da..21193fd 100644
> --- a/aio.7
> +++ b/aio.7
> @@ -281,12 +281,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
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] aio.7: Improve example
       [not found]     ` <56AF4AF9.9000807-fPG8STNUNVg@public.gmane.org>
@ 2016-02-01 14:25       ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Kerrisk (man-pages) @ 2016-02-01 14:25 UTC (permalink / raw)
  To: wharms-fPG8STNUNVg, Andreas Gruenbacher
  Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w, linux-man-u79uwXL29TY76Z2rM5mHXA

On 02/01/2016 01:09 PM, walter harms wrote:
> 
> 
> Am 01.02.2016 10:46, schrieb Andreas Gruenbacher:
>> When aio_sigevent.sigev_notify is set to SIGEV_SIGNAL, signal handlers
>> called for asychronous 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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>> ---
>>  aio.7 | 12 +++++++-----
>>  1 file changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/aio.7 b/aio.7
>> index 1f861da..21193fd 100644
>> --- a/aio.7
>> +++ b/aio.7
>> @@ -281,12 +281,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);
> 
> what about the replace write with dprintf ? dprintf is POSIX since 2008.

Hi Walter,

The problem there is that dprintf() is not async-signal-safe.

Cheers,

Michael



> re,
>  wh
> 
>>  
>> -    /* 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
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-02-01 14:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-01  9:46 [PATCH] aio.7: Improve example Andreas Gruenbacher
     [not found] ` <1454320018-14176-1-git-send-email-agruenba-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-02-01 12:09   ` walter harms
     [not found]     ` <56AF4AF9.9000807-fPG8STNUNVg@public.gmane.org>
2016-02-01 14:25       ` Michael Kerrisk (man-pages)
2016-02-01 14:23   ` Michael Kerrisk (man-pages)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.