Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ aio_return(3R) — SunOS 5.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

close(2)

exec(2)

exit(2)

fork(2)

lseek(2)

read(2)

write(2)

fsync(3C)

aio_cancel(3R)

aio_fsync(3R)

aio_read(3R)

lio_listio(3R)

aio_return(3R)

NAME

aio_return, aio_error − retrieve return or error status of asynchronous I/O operation

SYNOPSIS

cc [ flag ... ] file ... −lposix4 [ library ... ]

#include <aio.h>

ssize_t aio_return(struct aiocb ∗ aiocbp);

int aio_error(const struct aiocb ∗ aiocbp);

struct aiocb {
   intaio_fildes;/∗ file descriptor ∗/
   volatile void∗aio_buf;/∗ buffer location ∗/
   size_taio_nbytes;/∗ length of transfer ∗/
   off_taio_offset;/∗ file offset ∗/
   intaio_reqprio;/∗ request priority offset ∗/
   struct sigeventaio_sigevent;/∗ signal number and offset ∗/
   intaio_lio_opcode; /∗ listio operation ∗/
};

struct sigevent {
   intsigev_notify;/∗ notification mode ∗/
   intsigev_signo;/∗ signal number ∗/
   union sigvalsigev_value;/∗ signal value ∗/
};

union sigval {
   intsival_int;/∗ integer value ∗/
   void∗sival_ptr;/∗ pointer value ∗/
};

MT-LEVEL

Async-Safe

DESCRIPTION

aio_return() returns the return status of the asynchronous I/O request associated with the aiocb structure pointed to by aiocbp. 

aio_error() returns the error status of the asynchronous I/O request associated with the aiocb structure pointed to by aiocbp. 

aio_return() should be called only once to retrieve the valid return status of a given asynchronous operation, after aio_error() has returned a value other than
EINPROGRESS.

RETURN VALUES

If the asynchronous I/O operation has completed successfully, aio_return() returns the return status, as described for read(2), write(2), and fsync(3C). 

If the asynchronous I/O operation has completed successfully, aio_error() returns 0.  If the operation has not yet completed, then EINPROGRESS is returned.  If the asynchronous I/O operation has completed unsuccessfully, then the error status, as described for read(2), write(2), and fsync(3C) is returned. 

If unsuccessful, aio_return() or aio_error() return -1, and set errno to indicate the error condition. 

ERRORS

EINVAL aiocbp does not reference an asynchronous operation which has completed or failed. 

ENOSYS aio_return() or aio_error() is not supported by this implementation. 

EXAMPLES

#include <aio.h>
#include <errno.h>
#include <signal.h>
struct aiocbmy_aiocb;
struct sigactionmy_sigaction;
voidmy_aio_handler(int, siginfo_t ∗, void ∗);
...
my_sigaction.sa_flags = SA_SIGINFO;
my_sigaction.sa_sigaction = my_aio_handler;
sigsetempty(&my_sigaction.sa_mask);
(void) sigaction(SIGRTMIN, &my_sigaction, NULL);
...
my_aiocb.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
my_aiocb.aio_sigevent.sigev_signo = SIGRTMIN;
...
(void) aio_read(&my_aiocb);
...

void
my_aio_handler(int signo, siginfo_t ∗siginfo, void ∗context) {
intmy_errno;

if ((my_errno = aio_error(&my_aiocb)) != EINPROGRESS) {
intmy_status = aio_return(&my_aiocb);
if (my_status >= 0) {/∗ start another operation ∗/
...
} else{ /∗ handle I/O error ∗/
...
}
}
}

SEE ALSO

close(2), exec(2), exit(2), fork(2), lseek(2), read(2), write(2), fsync(3C), aio_cancel(3R), aio_fsync(3R), aio_read(3R), lio_listio(3R)

Sun Microsystems  —  Last change: 19 Aug 1993

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026