[newlib-cygwin] Cygwin: select: check for negative return from pipe_data_available
Ken Brown
kbrown@sourceware.org
Thu Sep 16 12:56:25 GMT 2021
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=18fab2f834cce4f0494610cc3085c5a1c6649635
commit 18fab2f834cce4f0494610cc3085c5a1c6649635
Author: Ken Brown <kbrown@cornell.edu>
Date: Wed Sep 15 12:56:34 2021 -0400
Cygwin: select: check for negative return from pipe_data_available
Make sure except_ready is set (if except_selected) on a negative
return from pipe_data_available.
Diff:
---
winsup/cygwin/select.cc | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index 566cf66d6..33c0c0bb0 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -753,8 +753,11 @@ out:
gotone += s->except_ready = true;
return gotone;
}
- gotone += s->write_ready = pipe_data_available (s->fd, fh, h, true);
- select_printf ("write: %s, gotone %d", fh->get_name (), gotone);
+ int n = pipe_data_available (s->fd, fh, h, true);
+ select_printf ("write: %s, n %d", fh->get_name (), n);
+ gotone += s->write_ready = n;
+ if (n < 0 && s->except_selected)
+ gotone += s->except_ready = true;
}
return gotone;
}
@@ -953,9 +956,11 @@ peek_fifo (select_record *s, bool from_select)
out:
if (s->write_selected)
{
- gotone += s->write_ready
- = pipe_data_available (s->fd, fh, fh->get_handle (), true);
- select_printf ("write: %s, gotone %d", fh->get_name (), gotone);
+ int n = pipe_data_available (s->fd, fh, fh->get_handle (), true);
+ select_printf ("write: %s, n %d", fh->get_name (), n);
+ gotone += s->write_ready = n;
+ if (n < 0 && s->except_selected)
+ gotone += s->except_ready = true;
}
return gotone;
}
@@ -1394,8 +1399,11 @@ out:
HANDLE h = ptys->get_output_handle ();
if (s->write_selected)
{
- gotone += s->write_ready = pipe_data_available (s->fd, fh, h, true);
- select_printf ("write: %s, gotone %d", fh->get_name (), gotone);
+ int n = pipe_data_available (s->fd, fh, h, true);
+ select_printf ("write: %s, n %d", fh->get_name (), n);
+ gotone += s->write_ready = n;
+ if (n < 0 && s->except_selected)
+ gotone += s->except_ready = true;
}
return gotone;
}
More information about the Cygwin-cvs
mailing list