vitek Key Veteran Location: Corvallis, OR
| To bad that only works in Windows. This should work in most other platforms, just not windows. Changed to using regular I/O because stdio and non-blocking stuff don't mix well.
//
// error checking omitted...
//
char buf[1];
int result;
int fd = STDIN_FILENO;
int fd_flags = fcntl(fd, F_GETFL, 0);
fd_flags |= O_NONBLOCK;
fcntl(fd, F_SETFL, fd_flags);
do {
write(fd, "xxx\n", 4);
result = read(fd, buf, sizeof(buf));
if (result == -1 && errno != EAGAIN)
break;
} while(*buf != '\n');
fd_flags &= ~O_NONBLOCK;
fcntl(fd, F_SETFL, fd_flags);
Travis |