Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to call <a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man2/aio_return.2.html#//apple_ref/doc/man/2/aio_return" rel="noreferrer"><code>aio_return(2)</code></a> exactly once for each asynchronous I/O operation. According to the note on that man page, failure to do so will leak resources, and it apparently also causes your problem. After you call <code>aio_suspend</code> to wait for the I/O to complete, make sure to call <code>aio_return</code> to get the number of bytes read, e.g.:</p> <pre><code>const struct aiocb *aio_l[] = {&amp;aio}; if (aio_suspend(aio_l, 1, 0) != 0) { printf("aio_suspend: %s\n", strerror(errno)); } else { printf("successfully read %d bytes\n", (int)aio_return(&amp;aio)); printf("%d\n", *(int *)aio.aio_buf); } </code></pre> <p>Also bear in mind these important notes from the <a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man2/aio_read.2.html" rel="noreferrer"><code>aio_read(2)</code></a> man page (emphasis mine):</p> <blockquote> <p>The Asynchronous I/O Control Block structure pointed to by <code>aiocbp</code> and the buffer that the <code>aiocbp-&gt;aio_buf</code> member of that structure references must remain valid until the operation has completed. For this reason, <strong>use of auto (stack) variables for these objects is discouraged</strong>.</p> <p>The asynchronous I/O control buffer <code>aiocbp</code> should be zeroed before the <code>aio_read()</code> call to avoid passing bogus context information to the kernel.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload