- if(fwrite(buf, 1, ret, out) != ret) {
- flog(LOG_ERR, "sendfile: could not write output: %s", strerror(errno));
- break;
+ if(ret > 0) {
+ if(pfds[0].revents & (POLLIN | POLLERR | POLLHUP)) {
+ ret = fread(buf, 1, 65536, in);
+ if(ferror(in)) {
+ flog(LOG_ERR, "callcgi: could not read input: %s", strerror(errno));
+ return(1);
+ }
+ if(fwrite(buf, 1, ret, out) != ret) {
+ flog(LOG_ERR, "callcgi: could not write output: %s", strerror(errno));
+ return(1);
+ }
+ }
+ if(pfds[1].revents & POLLHUP)
+ return(1);