Suppose you have an ocaml script file "foobar.ml" containing :
%< %< %< %< %< %< %< %< %< %< %< %< %< %<
#!/usr/bin/ocaml
#use "topfind";;
#require "netsys";;
while true do Printf.printf "toto\n%!"; done
%< %< %< %< %< %< %< %< %< %< %< %< %< %<
The command "ocaml foobar.ml | more" followed by a "q" key press ends up with :
Exception: Sys_error "Broken pipe".
Fatal error: exception Sys_error("Broken pipe")
When not requiring netsys, everything runs smoothly. Seems that the netsys module is messing sigpipe management without noticing.
This is intentional. Without that "messing", the program simply gets a sigpipe and dies (maybe it dies smoothly, I don't know). This way we get at least an exception. You can disable this behaviour with:
I've extended the documentation for Netsys_signal.