Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
to your account
Original bug ID: 7342
Assigned to: @protz
Status: resolved (set by @gasche on 2016-12-16T02:49:50Z)
Version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Target version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Fixed in version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Category: platform support (windows, cross-compilation, etc)
Monitored by: dsheets @gasche @hcarty
Reading Didier and Xavier's excellent "Unix programming in OCaml" course, I performed a Unix.read on a descriptor, expecting to read 0 when the descriptor had nothing left in it.
Sadly, I was developing on Windows. It turns out that Unix.read throws EPIPE there instead (see ocsigen/lwt#20 for another project that performed a workaround there).
See the attached file.
# #use "Test.ml";;
- : unit = ()
# run "ls" [||];;
Exception: Unix.Unix_error (Unix.EPIPE, "read", "").
The workaround is to remove the "when false" clause in Test.ml.
I can submit a pull request that wraps otherlibs/win32unix/unix.ml:read with that exact try-catch block, or I can submit a documentation request that documents this caveat. Any preference?
The text was updated successfully, but these errors were encountered:
Comment author: @gasche
As a mostly-unix programmer I would have a preference for the documented behavior (also in man 3 read on the C side) to work reliably on Windows -- I'm sure I would have been confused by the issue if people tried my software on Windows.
man 3 read
Sorry, something went wrong.
Comment author: @xavierleroy
Another Win32/Unix gratuitous difference, wonderful.
My preferred fix would be to change win32unix/read.c so that a GetLastError() code ERROR_BROKEN_PIPE is turned into a return of 0.
Comment author: @protz
Fixed by merging #797.
No branches or pull requests