pipe: use FLB_PIPE_WOULDBLOCK() to detect EAGAIN portably
Previously we tried to detect EAGAIN by checking errno. This works
fine on Unix, but does not work for Windows.
In order to be portable, we need to use FLB_PIPE_WOULDBLOCK() here.
@@ -131,7 +131,7 @@ ssize_t flb_pipe_read_all(int fd, void *buf, size_t count)
do {
bytes = flb_pipe_r(fd, (char *) buf + total, count - total);
if (bytes == -1) {
- if (errno == EAGAIN) {
+ if (FLB_PIPE_WOULDBLOCK()) {
/*
* This could happen, since this function goal is not to
* return until all data have been read, just sleep a little
@@ -162,7 +162,7 @@ ssize_t flb_pipe_write_all(int fd, void *buf, size_t count)
do {
bytes = flb_pipe_w(fd, (const char *) buf + total, count - total);
if (bytes == -1) {
- if (errno == EAGAIN) {
+ if (FLB_PIPE_WOULDBLOCK()) {
/*
* This could happen, since this function goal is not to
* return until all data have been read, just sleep a little
