diff options
| author | Alejandro Colomar <alx@kernel.org> | 2023-05-03 00:48:14 +0200 |
|---|---|---|
| committer | Alejandro Colomar <alx@kernel.org> | 2023-05-03 00:48:22 +0200 |
| commit | fe5dba139dc089eae4061fdc17f087e71f48b198 (patch) | |
| tree | 54af56b1b0138bde9a21e99372ab68ce4d64564a /man7/aio.7 | |
| parent | 5a0d9ed151e6449d978fabdd654cacc17b20a235 (diff) | |
| download | man-pages-fe5dba139dc089eae4061fdc17f087e71f48b198.tar.gz | |
man*/, man.ignore.grep: srcfix; warn about blank lines
- Use the dummy character to avoid warnings in examples.
- Re-enable the warning.
Suggested-by: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Diffstat (limited to 'man7/aio.7')
| -rw-r--r-- | man7/aio.7 | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/man7/aio.7 b/man7/aio.7 index 84613b622a..31edacf283 100644 --- a/man7/aio.7 +++ b/man7/aio.7 @@ -60,10 +60,10 @@ This structure has the following form: .in +4n .EX #include <aiocb.h> - +\& struct aiocb { /* The order of these fields is implementation\-dependent */ - +\& int aio_fildes; /* File descriptor */ off_t aio_offset; /* File offset */ volatile void *aio_buf; /* Location of buffer */ @@ -72,12 +72,12 @@ struct aiocb { struct sigevent aio_sigevent; /* Notification method */ int aio_lio_opcode; /* Operation to be performed; lio_listio() only */ - +\& /* Various implementation\-internal fields not shown */ }; - +\& /* Operation codes for \[aq]aio_lio_opcode\[aq]: */ - +\& enum { LIO_READ, LIO_WRITE, LIO_NOP }; .EE .in @@ -233,43 +233,43 @@ aio_return(): #include <errno.h> #include <aio.h> #include <signal.h> - +\& #define BUF_SIZE 20 /* Size of buffers for read operations */ - +\& #define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0) - +\& struct ioRequest { /* Application\-defined structure for tracking I/O requests */ int reqNum; int status; struct aiocb *aiocbp; }; - +\& static volatile sig_atomic_t gotSIGQUIT = 0; /* On delivery of SIGQUIT, we attempt to cancel all outstanding I/O requests */ - +\& static void /* Handler for SIGQUIT */ quitHandler(int sig) { gotSIGQUIT = 1; } - +\& #define IO_SIGNAL SIGUSR1 /* Signal used to notify I/O completion */ - +\& static void /* Handler for I/O completion signal */ aioSigHandler(int sig, siginfo_t *si, void *ucontext) { if (si\->si_code == SI_ASYNCIO) { write(STDOUT_FILENO, "I/O completion signal received\en", 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 */ } } - +\& int main(int argc, char *argv[]) { @@ -277,57 +277,57 @@ main(int argc, char *argv[]) int s; int numReqs; /* Total number of queued I/O requests */ int openReqs; /* Number of I/O requests still in progress */ - +\& if (argc < 2) { fprintf(stderr, "Usage: %s <pathname> <pathname>...\en", argv[0]); exit(EXIT_FAILURE); } - +\& numReqs = argc \- 1; - +\& /* Allocate our arrays. */ - +\& struct ioRequest *ioList = calloc(numReqs, sizeof(*ioList)); if (ioList == NULL) errExit("calloc"); - +\& struct aiocb *aiocbList = calloc(numReqs, sizeof(*aiocbList)); if (aiocbList == NULL) errExit("calloc"); - +\& /* Establish handlers for SIGQUIT and the I/O completion signal. */ - +\& sa.sa_flags = SA_RESTART; sigemptyset(&sa.sa_mask); - +\& sa.sa_handler = quitHandler; if (sigaction(SIGQUIT, &sa, NULL) == \-1) errExit("sigaction"); - +\& sa.sa_flags = SA_RESTART | SA_SIGINFO; sa.sa_sigaction = aioSigHandler; if (sigaction(IO_SIGNAL, &sa, NULL) == \-1) errExit("sigaction"); - +\& /* Open each file specified on the command line, and queue a read request on the resulting file descriptor. */ - +\& for (size_t j = 0; j < numReqs; j++) { ioList[j].reqNum = j; ioList[j].status = EINPROGRESS; ioList[j].aiocbp = &aiocbList[j]; - +\& ioList[j].aiocbp\->aio_fildes = open(argv[j + 1], O_RDONLY); if (ioList[j].aiocbp\->aio_fildes == \-1) errExit("open"); printf("opened %s on descriptor %d\en", argv[j + 1], ioList[j].aiocbp\->aio_fildes); - +\& ioList[j].aiocbp\->aio_buf = malloc(BUF_SIZE); if (ioList[j].aiocbp\->aio_buf == NULL) errExit("malloc"); - +\& ioList[j].aiocbp\->aio_nbytes = BUF_SIZE; ioList[j].aiocbp\->aio_reqprio = 0; ioList[j].aiocbp\->aio_offset = 0; @@ -335,27 +335,27 @@ main(int argc, char *argv[]) ioList[j].aiocbp\->aio_sigevent.sigev_signo = IO_SIGNAL; ioList[j].aiocbp\->aio_sigevent.sigev_value.sival_ptr = &ioList[j]; - +\& s = aio_read(ioList[j].aiocbp); if (s == \-1) errExit("aio_read"); } - +\& openReqs = numReqs; - +\& /* Loop, monitoring status of I/O requests. */ - +\& while (openReqs > 0) { sleep(3); /* Delay between each monitoring step */ - +\& if (gotSIGQUIT) { - +\& /* On receipt of SIGQUIT, attempt to cancel each of the outstanding I/O requests, and display status returned from the cancelation requests. */ - +\& printf("got SIGQUIT; canceling I/O requests: \en"); - +\& for (size_t j = 0; j < numReqs; j++) { if (ioList[j].status == EINPROGRESS) { printf(" Request %zu on descriptor %d:", j, @@ -372,20 +372,20 @@ main(int argc, char *argv[]) perror("aio_cancel"); } } - +\& gotSIGQUIT = 0; } - +\& /* Check the status of each I/O request that is still in progress. */ - +\& printf("aio_error():\en"); for (size_t j = 0; j < numReqs; j++) { if (ioList[j].status == EINPROGRESS) { printf(" for request %zu (descriptor %d): ", j, ioList[j].aiocbp\->aio_fildes); ioList[j].status = aio_error(ioList[j].aiocbp); - +\& switch (ioList[j].status) { case 0: printf("I/O succeeded\en"); @@ -400,26 +400,26 @@ main(int argc, char *argv[]) perror("aio_error"); break; } - +\& if (ioList[j].status != EINPROGRESS) openReqs\-\-; } } } - +\& printf("All I/O requests completed\en"); - +\& /* Check status return of all I/O requests. */ - +\& printf("aio_return():\en"); for (size_t j = 0; j < numReqs; j++) { ssize_t s; - +\& s = aio_return(ioList[j].aiocbp); printf(" for request %zu (descriptor %d): %zd\en", j, ioList[j].aiocbp\->aio_fildes, s); } - +\& exit(EXIT_SUCCESS); } .EE |
