summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Brown <kbrown@cornell.edu>2019-04-14 19:15:59 +0000
committerCorinna Vinschen <corinna@vinschen.de>2019-04-16 12:54:43 +0200
commit10bf30bebf7feebbc3e376cbcac62a242cc240f3 (patch)
tree17e32b62492b95aef06363bfdf3db4d3d08fcb93
parent513f050cbf1b9e1ac40e08d258e496272bde920f (diff)
downloadcygnal-10bf30bebf7feebbc3e376cbcac62a242cc240f3.tar.gz
cygnal-10bf30bebf7feebbc3e376cbcac62a242cc240f3.tar.bz2
cygnal-10bf30bebf7feebbc3e376cbcac62a242cc240f3.zip
Cygwin: check for STATUS_PENDING in fhandler_base::raw_read
If NtReadFile returns STATUS_PENDING, wait for the read to complete. This can happen, for instance, in the case of a FIFO opened with O_RDRW.
-rw-r--r--winsup/cygwin/fhandler.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index b0c9c50c3..a0c3dcce2 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -215,11 +215,23 @@ fhandler_base::raw_read (void *ptr, size_t& len)
NTSTATUS status;
IO_STATUS_BLOCK io;
int try_noreserve = 1;
+ DWORD waitret = WAIT_OBJECT_0;
retry:
status = NtReadFile (get_handle (), NULL, NULL, NULL, &io, ptr, len,
NULL, NULL);
- if (NT_SUCCESS (status))
+ if (status == STATUS_PENDING)
+ {
+ waitret = cygwait (get_handle (), cw_infinite,
+ cw_cancel | cw_sig_eintr);
+ if (waitret == WAIT_OBJECT_0)
+ status = io.Status;
+ }
+ if (waitret == WAIT_CANCELED)
+ pthread::static_cancel_self ();
+ else if (waitret == WAIT_SIGNALED)
+ set_errno (EINTR);
+ else if (NT_SUCCESS (status))
len = io.Information;
else
{