unsigned buf_avail;
char *buf_next;
bool pending;
+ bool eof;
};
priv->buf_avail = 0;
priv->buf_next = priv->buffer;
priv->pending = false;
+ priv->eof = false;
}
EventReader::~EventReader()
if(!ReadFile(*handle, priv->buffer, priv->buf_size, &ret, &priv->overlapped))
{
unsigned err = GetLastError();
- if(err==ERROR_IO_PENDING)
+ if(err==ERROR_BROKEN_PIPE)
+ priv->eof = true;
+ else if(err==ERROR_IO_PENDING)
priv->pending = true;
else
throw system_error("ReadFile");
DWORD ret;
if(!GetOverlappedResult(*handle, &priv->overlapped, &ret, true))
- throw system_error("GetOverlappedResult");
+ {
+ DWORD err = GetLastError();
+ if(err==ERROR_BROKEN_PIPE)
+ priv->eof = true;
+ else
+ throw system_error("GetOverlappedResult");
+ }
else
{
priv->buf_avail = ret;
{
if(!priv->buf_avail)
{
+ if(priv->eof)
+ return 0;
+
// No data in buffer, try to get some
start();
wait();