mirror of /home/gitosis/repositories/libowfat.git
Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat
https://www.fefe.de/libowfat/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
580 B
27 lines
580 B
#include <unistd.h> |
|
#include <poll.h> |
|
#include <errno.h> |
|
#include "io_internal.h" |
|
|
|
int64 io_waitread(int64 d,char* buf,int64 len) { |
|
long r; |
|
struct pollfd p; |
|
io_entry* e=array_get(&io_fds,sizeof(io_entry),d); |
|
if (!e) { errno=EBADF; return -3; } |
|
if (e->nonblock) { |
|
again: |
|
p.fd=d; |
|
if (p.fd != d) { errno=EBADF; return -3; } /* catch overflow */ |
|
p.events=POLLIN; |
|
switch (poll(&p,1,-1)) { |
|
case -1: if (errno==EAGAIN) goto again; return -3; |
|
} |
|
} |
|
r=read(d,buf,len); |
|
if (r==-1) { |
|
if (errno==EAGAIN) |
|
goto again; |
|
r=-3; |
|
} |
|
return r; |
|
}
|
|
|