Writing cat in OCaml: use of Unix.read Writing cat in OCaml: use of Unix.read unix unix

Writing cat in OCaml: use of Unix.read


The return of Unix.read (which you ignore, except checking for 0) is the number of characters that you've read, so you only should use that many characters of the buffer.

But really, why bother using the low-level Unix stuff? Why not use the regular OCaml file opening and reading functions?