-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Unix.read exhibits two different behaviors on Windows vs Linux #7342
Description
Original bug ID: 7342
Reporter: @protz
Assigned to: @protz
Status: resolved (set by @gasche on 2016-12-16T02:49:50Z)
Resolution: fixed
Priority: normal
Severity: minor
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
Bug description
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).
Steps to reproduce
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.
Additional information
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?