X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=ao-tools%2Flibaltos%2Flibaltos.c;h=465f0ac89475c03d61b1b89067a7b4b05ef67e4a;hp=059d2ae93b7e8c7d66776f28931f22b2e25e24ea;hb=357826aa9c7b42c59f5d52b8eb016d73b6da0c7f;hpb=35d9a8214252dbe79aeb69ae47d2e5c58a654702 diff --git a/ao-tools/libaltos/libaltos.c b/ao-tools/libaltos/libaltos.c index 059d2ae9..465f0ac8 100644 --- a/ao-tools/libaltos/libaltos.c +++ b/ao-tools/libaltos/libaltos.c @@ -576,6 +576,11 @@ altos_free(struct altos_file *file) PUBLIC int altos_flush(struct altos_file *file) { + if (file->out_used && 0) { + printf ("flush \""); + fwrite(file->out_data, 1, file->out_used, stdout); + printf ("\"\n"); + } while (file->out_used) { int ret; @@ -634,7 +639,7 @@ altos_fill(struct altos_file *file, int timeout) return LIBALTOS_ERROR; #ifdef USE_POLL fd[0].fd = file->fd; - fd[0].events = POLLIN; + fd[0].events = POLLIN|POLLERR|POLLHUP|POLLNVAL; fd[1].fd = file->pipe[0]; fd[1].events = POLLIN; ret = poll(fd, 2, timeout); @@ -644,6 +649,9 @@ altos_fill(struct altos_file *file, int timeout) } if (ret == 0) return LIBALTOS_TIMEOUT; + + if (fd[0].revents & (POLLHUP|POLLERR|POLLNVAL)) + return LIBALTOS_ERROR; if (fd[0].revents & POLLIN) #endif { @@ -660,6 +668,11 @@ altos_fill(struct altos_file *file, int timeout) #endif } } + if (file->in_used && 0) { + printf ("fill \""); + fwrite(file->in_data, 1, file->in_used, stdout); + printf ("\"\n"); + } return 0; }