teach manpages about largefile's demise
[unleashed.git] / share / man / man3c / aio_error.3c
blob631df08393de223d1412b030301510518f498216
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright 1989 AT&T
44 .\" Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
45 .\" Copyright (c) 2008, Sun Microsystems, Inc.  All Rights Reserved.
46 .\"
47 .TH AIO_ERROR 3C "Feb 5, 2008"
48 .SH NAME
49 aio_error \- retrieve errors status for an asynchronous I/O operation
50 .SH SYNOPSIS
51 .LP
52 .nf
53 #include <aio.h>
55 \fBint\fR \fBaio_error\fR(\fBconst struct aiocb *\fR\fIaiocbp\fR);
56 .fi
58 .SH DESCRIPTION
59 .sp
60 .LP
61 The \fBaio_error()\fR function returns the error status associated with the
62 \fBaiocb\fR structure referenced by the \fIaiocbp\fR argument. The error status
63 for an asynchronous I/O operation is the \fBerrno\fR value that would be set by
64 the corresponding \fBread\fR(2), \fBwrite\fR(2), or \fBfsync\fR(3C) operation.
65 If the operation has not yet completed, then the error status will be equal to
66 \fBEINPROGRESS\fR.
67 .SH RETURN VALUES
68 .sp
69 .LP
70 If the asynchronous I/O operation has completed successfully, then \fB0\fR is
71 returned. If the asynchronous operation has completed unsuccessfully, then the
72 error status, as described for \fBread\fR(2), \fBwrite\fR(2), and
73 \fBfsync\fR(3C), is returned. If the asynchronous I/O operation has not yet
74 completed, then \fBEINPROGRESS\fR is returned.
75 .SH ERRORS
76 .sp
77 .LP
78 The \fBaio_error()\fR function may fail if:
79 .sp
80 .ne 2
81 .na
82 \fB\fBEINVAL\fR\fR
83 .ad
84 .RS 10n
85 The \fIaiocbp\fR argument does not refer to an asynchronous operation whose
86 return status has not yet been retrieved.
87 .RE
89 .SH EXAMPLES
90 .LP
91 \fBExample 1 \fRThe following is an example of an error handling routine using
92 the \fBaio_error()\fR function.
93 .sp
94 .in +2
95 .nf
96 #include <aio.h>
97 #include <errno.h>
98 #include <signal.h>
99 struct aiocb      my_aiocb;
100 struct sigaction  my_sigaction;
101 void              my_aio_handler(int, siginfo_t *, void *);
102 \|.\|.\|.
103 my_sigaction.sa_flags = SA_SIGINFO;
104 my_sigaction.sa_sigaction = my_aio_handler;
105 sigemptyset(&my_sigaction.sa_mask);
106 (void) sigaction(SIGRTMIN, &my_sigaction, NULL);
107 \|.\|.\|.
108 my_aiocb.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
109 my_aiocb.aio_sigevent.sigev_signo = SIGRTMIN;
110 my_aiocb.aio_sigevent.sigev_value.sival_ptr = &myaiocb;
111 \|.\|.\|.
112 (void) aio_read(&my_aiocb);
113 \|.\|.\|.
114 void
115 my_aio_handler(int signo, siginfo_t *siginfo, void *context) {
116 int     my_errno;
117 struct aiocb    *my_aiocbp;
119 my_aiocbp = siginfo->si_value.sival_ptr;
120     if ((my_errno = aio_error(my_aiocb)) != EINPROGRESS) {
121         int my_status = aio_return(my_aiocb);
122             if (my_status >= 0){ /* start another operation */
123                     \|.\|.\|.
124             } else        { /* handle I/O error */
125                      \|.\|.\|.
126             }
127     }
130 .in -2
132 .SH ATTRIBUTES
135 See \fBattributes\fR(5) for descriptions of the following attributes:
140 box;
141 c | c
142 l | l .
143 ATTRIBUTE TYPE  ATTRIBUTE VALUE
145 Interface Stability     Committed
147 MT-Level        Async-Signal-Safe
149 Standard        See \fBstandards\fR(5).
152 .SH SEE ALSO
155 \fB_Exit\fR(2), \fBclose\fR(2), \fBfork\fR(2), \fBlseek\fR(2), \fBread\fR(2),
156 \fBwrite\fR(2), \fBaio.h\fR(3HEAD), \fBaio_cancel\fR(3C), \fBaio_fsync\fR(3C),
157 \fBaio_read\fR(3C), \fBaio_return\fR(3C), \fBaio_write\fR(3C),
158 \fBlio_listio\fR(3C), \fBsignal.h\fR(3HEAD), \fBattributes\fR(5),
159 \fBstandards\fR(5)