current status of Async I/O (io_submit & friends) on pipes
Hi!
Is the content of http://lse.sourceforge.net/io/aio.html still correct regarding support of pipes? Is there any up-to-date & authoritative interface description of io_submit & friends available?
This page tells me I'd receive EINVAL or the like when using async I/O on a pipe; however what I actually see on e.g. 2.6.23.1 is no error return, but an indefinite blocking in the io_submit syscall when the pipe is empty.
Is this expected behaviour?
Please put me on CC for any answer.
Here's a short snippet showing the behaviour. (link it against libaio - yes, I checked that libaio does nothing else than wrapping the syscalls).
------ SNIP -----
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <libaio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main() {
int filedes[2];
char buf;
io_context_t *ctx;
struct iocb * cb;
ctx=(io_context_t *)malloc(sizeof(io_context_t));
memset(ctx,0,sizeof(io_context_t));
cb=(struct iocb *)malloc(1*sizeof(struct iocb));
memset(cb,0,1*sizeof(struct iocb));
pipe(filedes);
cb[0].aio_lio_opcode=IO_CMD_PREAD;
cb[0].aio_fildes=filedes[0];
cb[0].u.c.buf=&buf;
cb[0].u.c.nbytes=1;
printf("before read\n");
/* program will block here */
printf("io_submit %i\n",io_submit(*ctx,1,&cb));
printf("read completed\n");
}Signature · 4 lines
Gernot Hillier Siemens AG, CT SE 2 Corporate Competence Center Embedded Linux