Re: Problems with aio_read
Re: Problems with aio_read
- Subject: Re: Problems with aio_read
- From: Terry Lambert <email@hidden>
- Date: Sat, 11 Oct 2008 09:19:25 -0700
On Oct 11, 2008, at 5:50 AM, Richard Schmitt <email@hidden>
wrote:
I'm trying to use aio_read in an application and am having problems
with the completion notifications.
When I use signals, I'll get a signal for the completion, but the
siginfo structure does not have the si_value filled in.
When I use notify functions, the aio_read call fails with invalid
argument.
Here's some sample code:
my_action.sa_sigaction = my_handler ;
my_action.sa_flags = SA_SIGINFO ;
sigaction (SIGIO, &my_action, NULL) ;
cb = malloc (sizeof (struct aiocb)) ;
memset (cb, '\0', sizeof (struct aiocb)) ;
cb->aio_fildes = open ("sigtest.c", O_NONBLOCK) ;
cb->aio_buf = malloc (1001) ;
cb->aio_nbytes = 1001 ;
cb->aio_offset = 0 ;
cb->aio_sigevent.sigev_value.sival_ptr = cb ;
cb->aio_sigevent.sigev_signo = SIGIO ;
cb->aio_sigevent.sigev_notify = SIGEV_SIGNAL ;
ret = aio_read (cb) ;
When the IO completes, I expect a SIGIO signal and the siginfo
structure passed to my_handler will have the si_value set to the
cb. The example handler is below:
void my_handler (int sig, siginfo_t *siginfo, void* context)
{
struct aiocb *cb ;
cb = siginfo->si_value.sival_ptr ;
cb is always NULL.
I'm running OSX 10.4.11
The aio implementation in 10.4 is not fully POSIX conformant. If your
code needs full POSIX conformance, it should be including <unistd.h>
and checking _POSIX_ASYNCHRONUS_IO has a value greater than or equal
to 200112L before using the interface.
There are a number of workaround that you could use if you wanted to
run on something as old as 10.4, but you would need to explain the
problem you are trying to solve for us to tell you which ones might be
appropriate.
-- Terry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden