Hello,
Sort of a followup to the previous discussion.
Trying to use streamio with O_NONBLOCK and select results in select claiming
that the fd is readable but when trying to read returning EWOULDBLOCK.
Removing the O_NONBLOCK check in io_select_common makes select behave (I tried
with timeout of NULL, 0 and 10s) however the input_buffer stays empty forever
so it is never woken up. Any ideas?
Here is some example code for trying to read 1 char from /dev/klog translated
with /hurd/streamio kmsg.
--8<---------------cut here---------------start------------->8---
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#define _PATH_KLOG "/dev/klog"
int
main ()
{
int fd;
fd = open(_PATH_KLOG, O_RDONLY | O_NONBLOCK);
if (fd < 0)
{
perror("open");
exit(EXIT_FAILURE);
}
char buffer[1];
ssize_t num_read;
fd_set fds;
FD_ZERO(&fds);
FD_SET(fd, &fds);
select(fd + 1, &fds, NULL, NULL, NULL);
if (FD_ISSET(fd, &fds))
{
num_read = read(fd, buffer, sizeof(buffer));
printf("num_read %d\n", num_read);
perror("read");
}
close(fd);
exit(EXIT_SUCCESS);
}
--8<---------------cut here---------------end--------------->8---
Output:./select
num_read -1
read: Resource temporarily unavailable